home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / ab20 / languags / cpp / gcgp1409.lha / src / g++-1.40.3 / cplus-lex.c next >
Encoding:
C/C++ Source or Header  |  1992-01-27  |  101.4 KB  |  4,059 lines

  1. /* Separate lexical analyzer for GNU C++.
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.    Hacked by Michael Tiemann (tiemann@mcc.com)
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. /* This file is the lexical analyzer for GNU C++.  */
  23.  
  24. #include <sys/types.h>
  25. #include <stdio.h>
  26. #include <errno.h>
  27. #include <setjmp.h>
  28. #include <string.h>
  29. #include "config.h"
  30. #include "input.h"
  31. #include "tree.h"
  32. #ifdef VMS
  33. #define _IOFBF 2        /* Missing from GNU's stdio.h */
  34. #endif
  35. #include "cplus-tab.h"
  36. #include "cplus-parse.h"
  37. #include "cplus-tree.h"
  38. #include "flags.h"
  39. #include "obstack.h"
  40. #include "assert.h"
  41.  
  42. /* Define getpagesize () if the system does not.  */
  43. #include "getpagesize.h"
  44.  
  45. extern int errno;        /* needed for VAX.  */
  46. extern jmp_buf toplevel;
  47.  
  48. #ifdef VMS
  49. #define    NULL_FILE    "nla0:"
  50. #else
  51. #ifdef amigados
  52. #define NULL_FILE    "nil:"
  53. #else
  54. #define    NULL_FILE    "/dev/null"
  55. #endif
  56. #endif
  57.  
  58. #define obstack_chunk_alloc xmalloc
  59. #define obstack_chunk_free free
  60.  
  61. extern int xmalloc ();
  62. extern void free ();
  63.  
  64. extern double atof ();
  65.  
  66. /* If you don't have strrchr, but instead have rindex,
  67.    add your machine to this list, and send mail to
  68.    tiemann@wheaties.ai.mit.edu.  */
  69. #if defined(sequent) || defined(convex)
  70. #define strrchr rindex
  71. #endif
  72. extern char *strrchr ();
  73.  
  74. /* This obstack is needed to hold text.  It is not safe to use
  75.    TOKEN_BUFFER because `check_newline' calls `yylex'.  */
  76. static struct obstack inline_text_obstack;
  77. static char *inline_text_firstobj;
  78.  
  79. /* Holds translations from TREE_CODEs to operator name strings,
  80.    i.e., opname_tab[PLUS_EXPR] == "+".  */
  81. char **opname_tab;
  82. char **assignop_tab;
  83.  
  84. #define YYEMPTY        -2
  85. int    yychar;            /*  the lookahead symbol        */
  86. YYSTYPE    yylval;            /*  the semantic value of the        */
  87.                 /*  lookahead symbol            */
  88.  
  89. #if 0
  90. YYLTYPE yylloc;            /*  location data for the lookahead    */
  91.                 /*  symbol                */
  92. #endif
  93.  
  94. int end_of_file;
  95.  
  96. /* the declaration found for the last IDENTIFIER token read in.
  97.    yylex must look this up to detect typedefs, which get token type TYPENAME,
  98.    so it is left around in case the identifier is not a typedef but is
  99.    used in a context which makes it a reference to a variable.  */
  100. tree lastiddecl;
  101.  
  102. /* C++ extensions */
  103. tree ridpointers[];        /* need this up here */
  104.  
  105. /* We may keep statistics about how long which files took to compile.  */
  106. static int header_time, body_time;
  107. static tree get_time_identifier ();
  108. static tree filename_times;
  109. static tree this_filename_time;
  110.  
  111. /* For implementing #pragma unit.  */
  112. tree current_unit_name;
  113. tree current_unit_language;
  114.  
  115. /* Array for holding counts of the numbers of tokens seen.  */
  116. int *token_count;
  117.  
  118. /* Return something to represent absolute declarators containing a *.
  119.    TARGET is the absolute declarator that the * contains.
  120.    TYPE_QUALS is a list of modifiers such as const or volatile
  121.    to apply to the pointer type, represented as identifiers.
  122.  
  123.    We return an INDIRECT_REF whose "contents" are TARGET
  124.    and whose type is the modifier list.  */
  125.  
  126. tree
  127. make_pointer_declarator (type_quals, target)
  128.      tree type_quals, target;
  129. {
  130.   if (target && TREE_CODE (target) == IDENTIFIER_NODE
  131.       && ANON_AGGRNAME_P (target))
  132.     error ("type name expected before `*'");
  133.   return build1 (INDIRECT_REF, type_quals, target);
  134. }
  135.  
  136. /* Return something to represent absolute declarators containing a &.
  137.    TARGET is the absolute declarator that the & contains.
  138.    TYPE_QUALS is a list of modifiers such as const or volatile
  139.    to apply to the reference type, represented as identifiers.
  140.  
  141.    We return an ADDR_EXPR whose "contents" are TARGET
  142.    and whose type is the modifier list.  */
  143.    
  144. tree
  145. make_reference_declarator (type_quals, target)
  146.      tree type_quals, target;
  147. {
  148.   if (target)
  149.     {
  150.       if (TREE_CODE (target) == ADDR_EXPR)
  151.     {
  152.       error ("cannot declare references to references");
  153.       return target;
  154.     }
  155.       if (TREE_CODE (target) == INDIRECT_REF)
  156.     {
  157.       error ("cannot declare pointers to references");
  158.       return target;
  159.     }
  160.       if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
  161.       error ("type name expected before `&'");
  162.     }
  163.   return build1 (ADDR_EXPR, type_quals, target);
  164. }
  165.  
  166. /* Given a chain of STRING_CST nodes,
  167.    concatenate them into one STRING_CST
  168.    and give it a suitable array-of-chars data type.  */
  169.  
  170. tree
  171. combine_strings (strings)
  172.      tree strings;
  173. {
  174.   register tree value, t;
  175.   register int length = 1;
  176.   int wide_length = 0;
  177.   int wide_flag = 0;
  178.  
  179.   if (TREE_CHAIN (strings))
  180.     {
  181.       /* More than one in the chain, so concatenate.  */
  182.       register char *p, *q;
  183.  
  184.       /* Don't include the \0 at the end of each substring,
  185.      except for the last one.
  186.      Count wide strings and ordinary strings separately.  */
  187.       for (t = strings; t; t = TREE_CHAIN (t))
  188.     {
  189.       if (TREE_TYPE (t) == int_array_type_node)
  190.         {
  191.           wide_length += (TREE_STRING_LENGTH (t) - 1);
  192.           wide_flag = 1;
  193.         }
  194.       else
  195.         length += (TREE_STRING_LENGTH (t) - 1);
  196.     }
  197.  
  198.       /* If anything is wide, the non-wides will be converted,
  199.      which makes them take more space.  */
  200.       if (wide_flag)
  201.     length = length * UNITS_PER_WORD + wide_length;
  202.  
  203.       p = (char *) savealloc (length);
  204.  
  205.       /* Copy the individual strings into the new combined string.
  206.      If the combined string is wide, convert the chars to ints
  207.      for any individual strings that are not wide.  */
  208.  
  209.       q = p;
  210.       for (t = strings; t; t = TREE_CHAIN (t))
  211.     {
  212.       int len = TREE_STRING_LENGTH (t) - 1;
  213.       if ((TREE_TYPE (t) == int_array_type_node) == wide_flag)
  214.         {
  215.           bcopy (TREE_STRING_POINTER (t), q, len);
  216.           q += len;
  217.         }
  218.       else
  219.         {
  220.           int i;
  221.           for (i = 0; i < len; i++)
  222.         ((int *) q)[i] = TREE_STRING_POINTER (t)[i];
  223.           q += len * UNITS_PER_WORD;
  224.         }
  225.     }
  226.       *q = 0;
  227.  
  228.       value = make_node (STRING_CST);
  229.       TREE_STRING_POINTER (value) = p;
  230.       TREE_STRING_LENGTH (value) = length;
  231.       TREE_LITERAL (value) = 1;
  232.     }
  233.   else
  234.     {
  235.       value = strings;
  236.       length = TREE_STRING_LENGTH (value);
  237.       if (TREE_TYPE (value) == int_array_type_node)
  238.     wide_flag = 1;
  239.     }
  240.  
  241.   /* Create the array type for the string constant.
  242.      -Wwrite-strings says make the string constant an array of const char
  243.      so that copying it to a non-const pointer will get a warning.  */
  244.   if (warn_write_strings)
  245.     {
  246.       tree elements
  247.     = build_type_variant (wide_flag ? integer_type_node : char_type_node,
  248.                   1, 0);
  249.       TREE_TYPE (value)
  250.     = build_array_type (elements,
  251.                 build_index_type (build_int_2 (length - 1, 0)));
  252.     }
  253.   else
  254.     TREE_TYPE (value)
  255.       = build_array_type (wide_flag ? integer_type_node : char_type_node,
  256.               build_index_type (build_int_2 (length - 1, 0)));
  257.   TREE_LITERAL (value) = 1;
  258.   TREE_STATIC (value) = 1;
  259.   return value;
  260. }
  261.  
  262. /* Build names and nodes for overloaded operators.  */
  263.  
  264. /* Memoized table for operator names.  */
  265. tree *node_table;
  266.  
  267. tree
  268. build_opid (code1, code2)
  269.      enum tree_code code1, code2;
  270. {
  271.   register tree t = make_node (OP_IDENTIFIER);
  272.   register tree tmp;
  273.   extern struct obstack *expression_obstack, permanent_obstack;
  274.   struct obstack *ambient_obstack = expression_obstack;
  275.   expression_obstack = &permanent_obstack;
  276.   if (code1 != 0)
  277.     {
  278.       if ((tmp = node_table[(int)code1]) == 0)
  279.     node_table[(int)code1] = tmp = make_node (code1);
  280.       TREE_PURPOSE (t) = tmp;
  281.     }
  282.   if ((tmp = node_table[(int)code2]) == 0)
  283.     node_table[(int)code2] = tmp = make_node (code2);
  284.   TREE_VALUE (t) = tmp;
  285.   expression_obstack = ambient_obstack;
  286.   return t;
  287. }
  288.  
  289. #ifdef __GNUC__
  290. #define DEFTREECODE(SYM, NAME, TYPE, LEN) sizeof (NAME),
  291. #else
  292. #define DEFTREECODE(SYM, NAME, TYPE, LEN) -1,
  293. #endif
  294. static short opname_end[] = {
  295. #include "tree.def"
  296. 7,                /* sizeof ("@@dummy"), */
  297. #include "cplus-tree.def"
  298. };
  299. #undef DEFTREECODE
  300.  
  301. /* Given a TOKEN and its estimated tree code CODE, produce a name which
  302.    can be recognized by lookup_name.  Based on the number of PARMS,
  303.    build an appropriate operator fnname.  This function is needed because
  304.    until we know how many parameters we have, we cannot reliably tell
  305.    what function indeed we are trying to declare.
  306.  
  307.    NPARMS is the number of additional parameters that this operator
  308.    will ultimately have.  If NPARMS == -1, then we are just building
  309.    a name, and should not complain.
  310.  
  311.    This would be a good candidate for memoizing.  */
  312. tree
  313. build_operator_fnname (declp, parms, nparms)
  314.      tree *declp;
  315.      tree parms;
  316.      int nparms;
  317. {
  318.   tree decl = *declp;
  319.   char **opname_table, *opname;
  320.   int assignop_p = 0;
  321.   tree rval;
  322.   enum tree_code code;
  323.   char buf[1024];
  324.   int saw_class = nparms;
  325.   int erred = 0;
  326.  
  327.   while (parms)
  328.     {
  329.       tree type;
  330.       if (parms == void_list_node)
  331.     break;
  332.  
  333.       if (! saw_class)
  334.     {
  335.       type = TREE_VALUE (parms);
  336.       if (TREE_CODE (type) == REFERENCE_TYPE)
  337.         type = TREE_TYPE (type);
  338.       if (TREE_CODE (type) == POINTER_TYPE)
  339.         type = TREE_TYPE (type);
  340.       if (IS_AGGR_TYPE (type))
  341.         saw_class = 1;
  342.     }
  343.       nparms++;
  344.       parms = TREE_CHAIN (parms);
  345.     }
  346.  
  347.   if (TREE_CODE (decl) == TYPE_EXPR)
  348.     {
  349.       /* @@ may need to perform type instantiation here.  */
  350.       if (nparms > 1)
  351.     error ("wrong number of arguments to type conversion operator");
  352.  
  353.       /* The grammar will swallow an "()" if one was given.
  354.      We attempt to correct for this lossage here.  */
  355.       if (TREE_OPERAND (decl, 0)
  356.       && TREE_CODE (TREE_OPERAND (decl, 0)) == CALL_EXPR)
  357.     {
  358.       rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), NULL_TREE)));
  359.       yychar = LEFT_RIGHT;
  360.     }
  361.       else
  362.     {
  363.       rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), TREE_OPERAND (decl, 0))));
  364.     }
  365.       return rval;
  366.     }
  367.  
  368.   if (TREE_PURPOSE (decl))
  369.     if (TREE_CODE (TREE_PURPOSE (decl)) == MODIFY_EXPR)
  370.       {
  371.     opname_table = assignop_tab;
  372.     assignop_p = 1;
  373.       }
  374.     else
  375.       abort ();
  376.   else
  377.     opname_table = opname_tab;
  378.  
  379.   code = TREE_CODE (TREE_VALUE (decl));
  380.   opname = opname_table[(int) code];
  381.  
  382.   if (assignop_p)
  383.     {
  384.       if (nparms == 1 || nparms > 2)
  385.     error ("wrong number of parameters op `operator %s'", opname);
  386.     }
  387.   else switch (code)
  388.     {
  389.     case ERROR_MARK:
  390.       rval = get_identifier ("<invalid operator>");
  391.       TREE_OVERLOADED (rval) = 1;
  392.       return rval;
  393.  
  394.       /* AC/DC */
  395.     case PLUS_EXPR:
  396.       if (nparms == 1)
  397.     code = CONVERT_EXPR;
  398.       else if (nparms != 2)
  399.     erred = 1;
  400.       break;
  401.  
  402.     case ADDR_EXPR:
  403.     case BIT_AND_EXPR:
  404.       if (nparms == 1)
  405.     code = ADDR_EXPR;
  406.       else if (nparms == 2)
  407.     code = BIT_AND_EXPR;
  408.       else
  409.     {
  410.       code = BIT_AND_EXPR;
  411.       erred = 1;
  412.     }
  413.       break;
  414.  
  415.     case MULT_EXPR:
  416.     case INDIRECT_REF:
  417.       if (nparms == 1)
  418.     code = INDIRECT_REF;
  419.       else if (nparms == 2)
  420.     code = MULT_EXPR;
  421.       else
  422.     {
  423.       code = MULT_EXPR;
  424.       erred = 1;
  425.     }
  426.       break;
  427.  
  428.     case MINUS_EXPR:
  429.     case NEGATE_EXPR:
  430.       if (nparms == 1)
  431.     code = NEGATE_EXPR;
  432.       else if (nparms == 2)
  433.     code = MINUS_EXPR;
  434.       else
  435.     {
  436.       code = MINUS_EXPR;
  437.       erred = 1;
  438.     }
  439.       break;
  440.  
  441.     case POINTSAT:
  442.       if (nparms == 1 || nparms < 0)
  443.     code = COMPONENT_REF;
  444.       else
  445.     {
  446.       erred = -1;
  447.       error ("wrong number of parameters to `operator ->()'");
  448.     }
  449.       break;
  450.  
  451.     case METHOD_CALL_EXPR:
  452.       switch (nparms)
  453.     {
  454.     case 0:
  455.     case 1:
  456.       erred = -1;
  457.       error ("too few arguments to `operator ->()(...)'");
  458.       break;
  459.       /* 4 happens when we pass in the canonical number
  460.          of arguments.  */
  461.     case 4:
  462.       nparms = 3;
  463.     case -1:
  464.     case 2:
  465.     case 3:
  466.       break;
  467.     default:
  468.       erred = -1;
  469.       error ("too many arguments to `operator ->()(...)'");
  470.       break;
  471.     }
  472.       break;
  473.  
  474.       /* The two following entrys are for two different ways of
  475.      encoding `operator ='.  */
  476.     case NOP_EXPR:
  477.       if (nparms != 2 && nparms >= 0)
  478.     erred = 1;
  479.       break;
  480.  
  481.     case MODIFY_EXPR:
  482.       if (nparms != 2 && nparms >= 0)
  483.     erred = 1;
  484.       break;
  485.  
  486.     case NEW_EXPR:
  487.       if (saw_class == 0)
  488.     {
  489.       if (nparms > 1)
  490.         return get_identifier (OPERATOR_NEW_FORMAT);
  491.       return get_identifier ("__builtin_new");
  492.     }
  493.       break;
  494.  
  495.     case DELETE_EXPR:
  496.       if (saw_class == 0)
  497.     {
  498.       if (nparms > 1)
  499.         error ("too many parameters to `operator ::delete'");
  500.       return get_identifier ("__builtin_delete");
  501.     }
  502.       if (nparms > 2)
  503.     erred = 1;
  504.       break;
  505.  
  506.       /* Whatever it was, we know its arity.  Just check that it
  507.          has the right number of parameters defined.  */
  508.     default:
  509.       /* These are the only operators which do not need
  510.      to have a class-type associated with them.  */
  511.  
  512.       if (code == PREDECREMENT_EXPR
  513.       || code == POSTINCREMENT_EXPR
  514.       || code == COMPONENT_REF)
  515.     {
  516.       if (nparms > 1)
  517.         erred = 1;
  518.     }
  519.       else if (nparms < 0
  520.            || code == CALL_EXPR
  521.            || code == METHOD_CALL_EXPR)
  522.     ;
  523.       else if (nparms != tree_code_length [(int) code])
  524.     erred = 1;
  525.       break;
  526.     }
  527.  
  528.   if (erred > 0)
  529.     error ("wrong number of parameters to `operator %s'", opname);
  530.   else if (erred == 0 && code != TREE_CODE (TREE_VALUE (decl)))
  531.     {
  532.       enum tree_code assign_code = ERROR_MARK;
  533.       if (TREE_PURPOSE (decl))
  534.     assign_code = TREE_CODE (TREE_PURPOSE (decl));
  535.       decl = build_opid (assign_code, code);
  536.       *declp = decl;
  537.     }
  538.  
  539.   if (! saw_class)
  540.     error ("`operator %s' must have at least one class type", opname);
  541.  
  542.   if (assignop_p)
  543.     {
  544.       sprintf (buf, OPERATOR_ASSIGN_FORMAT, tree_code_name [(int) code]);
  545.       buf[opname_end[(int) code] + sizeof (OPERATOR_ASSIGN_FORMAT) - 3] = '\0';
  546.     }
  547.   else
  548.     {
  549.       sprintf (buf, OPERATOR_FORMAT, tree_code_name [(int) code]);
  550.       buf[opname_end[(int) code] + sizeof (OPERATOR_FORMAT) - 3] = '\0';
  551.     }      
  552.   rval = get_identifier (buf);
  553.   TREE_OVERLOADED (rval) = 1;
  554.   return rval;
  555. }
  556.  
  557. char *
  558. operator_name_string (name)
  559.      tree name;
  560. {
  561.   char *opname = IDENTIFIER_POINTER (name)
  562.     + sizeof (OPERATOR_FORMAT) - sizeof ("%s");
  563.   int i, assign;
  564.  
  565.   /* Works for builtin and user defined types.  */
  566.   if (IDENTIFIER_GLOBAL_VALUE (name)
  567.       && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
  568.     return IDENTIFIER_POINTER (name);
  569.  
  570.   if (! strncmp (opname, "assign", 6))
  571.     {
  572.       opname += 7;
  573.       assign = 1;
  574.     }
  575.   else
  576.     assign = 0;
  577.  
  578.   for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
  579.     {
  580.       if (! strncmp (opname, tree_code_name[i], opname_end[i]))
  581.     break;
  582.     }
  583.  
  584.   if (i == LAST_CPLUS_TREE_CODE)
  585.     return "<invalid operator>";
  586.  
  587.   if (assign)
  588.     return assignop_tab[i];
  589.   else
  590.     return opname_tab[i];
  591. }
  592.  
  593. int lineno;            /* current line number in file being read */
  594.  
  595. FILE *finput;            /* input file.
  596.                    Normally a pipe from the preprocessor.  */
  597. static FILE *finput1;        /* Real input files: 1 is main input file */
  598. static FILE *finput2;        /* 2 is input file for inline functions */
  599.  
  600. int interface_only;        /* whether or not current file is only for
  601.                    interface definitions.  */
  602. int interface_unknown;        /* whether or not we know this class
  603.                    to behave according to #pragma interface.  */
  604.  
  605. /* lexical analyzer */
  606.  
  607. static int maxtoken;        /* Current nominal length of token buffer.  */
  608. char *token_buffer;        /* Pointer to token buffer.
  609.                    Actual allocated length is maxtoken + 2.  */
  610. static int max_wide;        /* Current nominal length of wide_buffer.  */
  611. static int *wide_buffer;    /* Pointer to wide-string buffer.
  612.                    Actual allocated length is max_wide + 1.  */
  613.  
  614. #define NORID RID_UNUSED
  615.  
  616. /* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf  */
  617. struct resword { char *name; short token; enum rid rid;};
  618.  
  619. #define MIN_WORD_LENGTH 2
  620. #define MAX_WORD_LENGTH 13
  621. #define MIN_HASH_VALUE 4
  622. #define MAX_HASH_VALUE 147
  623. /*
  624.    71 keywords
  625.   144 is the maximum key range
  626. */
  627.  
  628. #ifdef __GNUC__
  629. inline
  630. #endif
  631. static int
  632. hash (str, len)
  633.      register char *str;
  634.      register int unsigned len;
  635. {
  636.   static unsigned char hash_table[] =
  637.     {
  638.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  639.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  640.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  641.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  642.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  643.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  644.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  645.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  646.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  647.      147, 147, 147, 147, 147,   0, 147,  19,   6,  27,
  648.       37,   0,  12,   1,  15,  63, 147,   4,   0,  56,
  649.       20,  15,  42, 147,  31,   5,  26,  39,  32,  10,
  650.      147,  40, 147, 147, 147, 147, 147, 147,
  651.     };
  652.   register int hval = len ;
  653.  
  654.   switch (hval)
  655.     {
  656.       default:
  657.       case 4:
  658.         hval += hash_table[str[3]];
  659.       case 3:
  660.       case 2:
  661.       case 1:
  662.         hval += hash_table[str[0]];
  663.     }
  664.   return hval + hash_table[str[len - 1]] ;
  665. }
  666.  
  667. #ifdef __GNUC__
  668. inline
  669. #endif
  670. struct resword *
  671. is_reserved_word (str, len)
  672.      register char *str;
  673.      register unsigned int len;
  674. {
  675.  
  676.   static struct resword  wordlist[] =
  677.     {
  678.       {"",}, {"",}, {"",}, {"",}, 
  679.       {"else",  ELSE, NORID,},
  680.       {"",}, 
  681.       {"long",  TYPESPEC, RID_LONG,},
  682.       {"",}, {"",}, {"",}, {"",}, 
  683.       {"__alignof__",  ALIGNOF, NORID},
  684.       {"__asm__",  ASM, NORID},
  685.       {"",}, {"",}, 
  686.       {"while",  WHILE, NORID,},
  687.       {"",}, {"",}, {"",}, {"",}, {"",}, 
  688.       {"__alignof",  ALIGNOF, NORID},
  689.       {"all",  ALL, NORID            /* Extension */,},
  690.       {"sizeof",  SIZEOF, NORID,},
  691.       {"__const__",  TYPE_QUAL, RID_CONST},
  692.       {"__volatile",  TYPE_QUAL, RID_VOLATILE},
  693.       {"extern",  SCSPEC, RID_EXTERN,},
  694.       {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
  695.       {"__inline",  SCSPEC, RID_INLINE},
  696.       {"exception",  AGGR, RID_EXCEPTION    /* Extension */,},
  697.       {"__inline__",  SCSPEC, RID_INLINE},
  698.       {"case",  CASE, NORID,},
  699.       {"except",  EXCEPT, NORID        /* Extension */,},
  700.       {"new",  NEW, NORID,},
  701.       {"break",  BREAK, NORID,},
  702.       {"goto",  GOTO, NORID,},
  703.       {"",}, 
  704.       {"__attribute",  ATTRIBUTE, NORID},
  705.       {"",}, 
  706.       {"__attribute__",  ATTRIBUTE, NORID},
  707.       {"this",  THIS, NORID,},
  708.       {"raise",  RAISE, NORID        /* Extension */,},
  709.       {"class",  AGGR, RID_CLASS,},
  710.       {"delete",  DELETE, NORID,},
  711.       {"typeof",  TYPEOF, NORID,},
  712.       {"typedef",  SCSPEC, RID_TYPEDEF,},
  713.       {"for",  FOR, NORID,},
  714.       {"raises",  RAISES, NORID        /* Extension */,},
  715.       {"__const",  TYPE_QUAL, RID_CONST},
  716.       {"double",  TYPESPEC, RID_DOUBLE,},
  717.       {"__typeof__",  TYPEOF, NORID},
  718.       {"",}, 
  719.       {"switch",  SWITCH, NORID,},
  720.       {"auto",  SCSPEC, RID_AUTO,},
  721.       {"do",  DO, NORID,},
  722.       {"friend",  SCSPEC, RID_FRIEND,},
  723.       {"",}, 
  724.       {"reraise",  RERAISE, NORID        /* Extension */,},
  725.       {"",}, 
  726.       {"volatile",  TYPE_QUAL, RID_VOLATILE,},
  727.       {"__typeof",  TYPEOF, NORID},
  728.       {"continue",  CONTINUE, NORID,},
  729.       {"float",  TYPESPEC, RID_FLOAT,},
  730.       {"const",  TYPE_QUAL, RID_CONST,},
  731.       {"static",  SCSPEC, RID_STATIC,},
  732.       {"virtual",  SCSPEC, RID_VIRTUAL,},
  733.       {"__asm",  ASM, NORID},
  734.       {"short",  TYPESPEC, RID_SHORT,},
  735.       {"signed",  TYPESPEC, RID_SIGNED,},
  736.       {"try",  TRY, NORID            /* Extension */,},
  737.       {"",}, {"",}, {"",}, 
  738.       {"__signed__",  TYPESPEC, RID_SIGNED},
  739.       {"catch",  CATCH, NORID,},
  740.       {"public",  PUBLIC, NORID,},
  741.       {"struct",  AGGR, RID_RECORD,},
  742.       {"if",  IF, NORID,},
  743.       {"asm",  ASM, NORID,},
  744.       {"union",  AGGR, RID_UNION,},
  745.       {"",}, 
  746.       {"private",  PRIVATE, NORID,},
  747.       {"",}, {"",}, {"",}, 
  748.       {"operator",  OPERATOR, NORID,},
  749.       {"",}, {"",}, {"",}, 
  750.       {"default",  DEFAULT, NORID,},
  751.       {"dynamic",  DYNAMIC, NORID,},
  752.       {"overload",  OVERLOAD, NORID,},
  753.       {"int",  TYPESPEC, RID_INT,},
  754.       {"char",  TYPESPEC, RID_CHAR,},
  755.       {"",}, {"",}, 
  756.       {"return",  RETURN, NORID,},
  757.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  758.       {"",}, {"",}, 
  759.       {"__signed",  TYPESPEC, RID_SIGNED},
  760.       {"",}, 
  761.       {"void",  TYPESPEC, RID_VOID,},
  762.       {"",}, {"",}, {"",}, 
  763.       {"protected",  PROTECTED, NORID,},
  764.       {"",}, 
  765.       {"enum",  ENUM, NORID,},
  766.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  767.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  768.       {"inline",  SCSPEC, RID_INLINE,},
  769.       {"register",  SCSPEC, RID_REGISTER,},
  770.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  771.       {"",}, {"",}, {"",}, {"",}, 
  772.       {"unsigned",  TYPESPEC, RID_UNSIGNED,},
  773.     };
  774.  
  775.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  776.     {
  777.       register int key = hash (str, len);
  778.  
  779.       if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
  780.         {
  781.           register char *s = wordlist[key].name;
  782.  
  783.           if (*s == *str && !strcmp (str + 1, s + 1))
  784.             return &wordlist[key];
  785.         }
  786.     }
  787.   return 0;
  788. }
  789.  
  790. /* The elements of `ridpointers' are identifier nodes
  791.    for the reserved type names and storage classes.
  792.    It is indexed by a RID_... value.  */
  793.  
  794. tree ridpointers[(int) RID_MAX];
  795.  
  796. int check_newline ();
  797.  
  798. static int skip_white_space ();
  799.  
  800. static tree
  801. get_time_identifier (name)
  802.      char *name;
  803. {
  804.   tree time_identifier;
  805.   int len = strlen (name);
  806.   char *buf = (char *)alloca (len + 6);
  807.   strcpy (buf, "file ");
  808.   bcopy (name, buf+5, len);
  809.   buf[len+5] = '\0';
  810.   time_identifier = get_identifier (buf);
  811.   if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
  812.     {
  813.       int temp = allocation_temporary_p ();
  814.       if (temp)
  815.     end_temporary_allocation ();
  816.       IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
  817.       IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
  818.       IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
  819.       filename_times = time_identifier;
  820.       if (temp)
  821.     resume_temporary_allocation ();
  822.     }
  823.   return time_identifier;
  824. }
  825.  
  826. #ifdef __GNUC__
  827. __inline
  828. #endif
  829. static int
  830. my_gettime ()
  831. {
  832.   int old_quiet_flag = quiet_flag;
  833.   int this_time;
  834.   quiet_flag = 0;
  835.   this_time = gettime ();
  836.   quiet_flag = old_quiet_flag;
  837.   return this_time;
  838. }
  839.  
  840. /* Table indexed by tree code giving a string containing a character
  841.    classifying the tree code.  Possibilities are
  842.    t, d, s, c, r and e.  See cplus-tree.def for details.  */
  843.  
  844. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
  845.  
  846. char *cplus_tree_code_type[] = {
  847.   "x",
  848. #include "cplus-tree.def"
  849. };
  850. #undef DEFTREECODE
  851.  
  852. /* Table indexed by tree code giving number of expression
  853.    operands beyond the fixed part of the node structure.
  854.    Not used for types or decls.  */
  855.  
  856. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
  857.  
  858. int cplus_tree_code_length[] = {
  859.   0,
  860. #include "cplus-tree.def"
  861. };
  862. #undef DEFTREECODE
  863.  
  864. /* Names of tree components.
  865.    Used for printing out the tree and error messages.  */
  866. #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
  867.  
  868. char *cplus_tree_code_name[] = {
  869.   "@@dummy",
  870. #include "cplus-tree.def"
  871. };
  872. #undef DEFTREECODE
  873.  
  874. void
  875. init_filename_times ()
  876. {
  877.   this_filename_time = get_time_identifier ("<top level>");
  878.   if (flag_detailed_statistics)
  879.     {
  880.       header_time = 0;
  881.       body_time = my_gettime ();
  882.       TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
  883.     }
  884. }
  885.  
  886. /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
  887.    Stuck this hack in to get the files open correctly; this is called
  888.    in place of init_lex if we are an unexec'd binary.    */
  889. void
  890. reinit_lex_for_unexec ()
  891. {
  892.   finput1 = finput;
  893.   finput2 = fopen (NULL_FILE, "r");
  894.   init_filename_times ();
  895. }
  896.  
  897. void
  898. init_lex ()
  899. {
  900.   extern int *init_parse ();
  901.   extern char *(*decl_printable_name) ();
  902.   extern char *lang_printable_name ();
  903.   extern struct rtx_def *(*lang_expand_expr) ();
  904.   extern struct rtx_def *cplus_expand_expr ();
  905.  
  906.   int i;
  907.  
  908.   /* Make identifier nodes long enough for the language-specific slots.  */
  909.   set_identifier_size (sizeof (struct lang_identifier));
  910.   decl_printable_name = lang_printable_name;
  911.   lang_expand_expr = cplus_expand_expr;
  912.  
  913.   tree_code_type
  914.     = (char **) realloc (tree_code_type,
  915.              sizeof (char *) * LAST_CPLUS_TREE_CODE);
  916.   tree_code_length
  917.     = (int *) realloc (tree_code_length,
  918.                sizeof (int) * LAST_CPLUS_TREE_CODE);
  919.   tree_code_name
  920.     = (char **) realloc (tree_code_name,
  921.              sizeof (char *) * LAST_CPLUS_TREE_CODE);
  922.   bcopy (cplus_tree_code_type,
  923.      tree_code_type + LAST_AND_UNUSED_TREE_CODE,
  924.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
  925.   bcopy (cplus_tree_code_length,
  926.      tree_code_length + LAST_AND_UNUSED_TREE_CODE,
  927.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
  928.   bcopy (cplus_tree_code_name,
  929.      tree_code_name + LAST_AND_UNUSED_TREE_CODE,
  930.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
  931.  
  932.   node_table = (tree *)oballoc (LAST_CPLUS_TREE_CODE * sizeof (tree));
  933.   opname_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *));
  934.   assignop_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *));
  935.  
  936.   for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
  937.     /* Our only interest is _ref and _expr.  */
  938.     if (tree_code_type[i][0] == 'r' || tree_code_type[i][0] == 'e')
  939.       {
  940.     char *end = (char *)strrchr (tree_code_name[i], '_');
  941.     if (end)
  942.       opname_end[i] = end - tree_code_name[i];
  943. #ifndef __GNUC__
  944.     else
  945.       opname_end[i] = strlen (tree_code_name[i]);
  946. #endif
  947.       }
  948. #ifndef __GNUC__
  949.     else
  950.       opname_end[i] = strlen (tree_code_name[i]);
  951. #endif
  952.  
  953.   init_method ();
  954.   obstack_init (&inline_text_obstack);
  955.   inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
  956.  
  957.   /* Start it at 0, because check_newline is called at the very beginning
  958.      and will increment it to 1.  */
  959.   lineno = 0;
  960.   finput1 = finput;
  961.   finput2 = fopen (NULL_FILE, "r");
  962.   current_function_decl = NULL;
  963.  
  964.   maxtoken = 40;
  965.   token_buffer = (char *) xmalloc (maxtoken + 2);
  966.   max_wide = 40;
  967.   wide_buffer = (int *) xmalloc (max_wide + 1);
  968.  
  969.   ridpointers[(int) RID_INT] = get_identifier ("int");
  970.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
  971.               build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
  972.   ridpointers[(int) RID_CHAR] = get_identifier ("char");
  973.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
  974.               build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
  975.   ridpointers[(int) RID_VOID] = get_identifier ("void");
  976.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
  977.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
  978.   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
  979.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
  980.               build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
  981.   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
  982.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
  983.               build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
  984.   ridpointers[(int) RID_SHORT] = get_identifier ("short");
  985.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
  986.               build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
  987.   ridpointers[(int) RID_LONG] = get_identifier ("long");
  988.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
  989.               build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
  990.   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
  991.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
  992.               build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
  993.   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
  994.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
  995.               build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
  996.   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
  997.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
  998.               build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
  999.   ridpointers[(int) RID_CONST] = get_identifier ("const");
  1000.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
  1001.               build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
  1002.   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
  1003.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
  1004.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
  1005.   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
  1006.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
  1007.               build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
  1008.   ridpointers[(int) RID_STATIC] = get_identifier ("static");
  1009.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
  1010.               build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
  1011.   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
  1012.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
  1013.               build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
  1014.   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
  1015.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
  1016.               build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
  1017.   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
  1018.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
  1019.               build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
  1020.  
  1021.   /* C++ extensions. These are probably not correctly named. */
  1022.   class_type_node = build_int_2 (class_type, 0);
  1023.   TREE_TYPE (class_type_node) = class_type_node;
  1024.   ridpointers[(int) RID_CLASS] = class_type_node;
  1025.  
  1026.   record_type_node = build_int_2 (record_type, 0);
  1027.   TREE_TYPE (record_type_node) = record_type_node;
  1028.   ridpointers[(int) RID_RECORD] = record_type_node;
  1029.  
  1030.   union_type_node = build_int_2 (union_type, 0);
  1031.   TREE_TYPE (union_type_node) = union_type_node;
  1032.   ridpointers[(int) RID_UNION] = union_type_node;
  1033.  
  1034.   enum_type_node = build_int_2 (enum_type, 0);
  1035.   TREE_TYPE (enum_type_node) = enum_type_node;
  1036.   ridpointers[(int) RID_ENUM] = enum_type_node;
  1037.  
  1038.   ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
  1039.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
  1040.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
  1041.   ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
  1042.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
  1043.               build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
  1044.  
  1045.   /* Exception handling extensions.  */
  1046.   exception_type_node = build_int_2 (exception_type, 0);
  1047.   TREE_TYPE (exception_type_node) = exception_type_node;
  1048.   ridpointers[(int) RID_EXCEPTION] = exception_type_node;
  1049.  
  1050.   opname_tab[(int) COMPONENT_REF] = "->";
  1051.   opname_tab[(int) METHOD_CALL_EXPR] = "->()";
  1052.   opname_tab[(int) INDIRECT_REF] = "(unary *)";
  1053.   opname_tab[(int) ARRAY_REF] = "[]";
  1054.   opname_tab[(int) MODIFY_EXPR] = "=";
  1055.   opname_tab[(int) NEW_EXPR] = "new";
  1056.   opname_tab[(int) DELETE_EXPR] = "delete";
  1057.   opname_tab[(int) COND_EXPR] = "... ? ... : ...";
  1058.   opname_tab[(int) CALL_EXPR] = "()";
  1059.   opname_tab[(int) PLUS_EXPR] = "+";
  1060.   opname_tab[(int) MINUS_EXPR] = "-";
  1061.   opname_tab[(int) MULT_EXPR] = "*";
  1062.   opname_tab[(int) TRUNC_DIV_EXPR] = "/";
  1063.   opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
  1064.   opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
  1065.   opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
  1066.   opname_tab[(int) TRUNC_MOD_EXPR] = "%";
  1067.   opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
  1068.   opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
  1069.   opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
  1070.   opname_tab[(int) NEGATE_EXPR] = "-";
  1071.   opname_tab[(int) MIN_EXPR] = "<?";
  1072.   opname_tab[(int) MAX_EXPR] = ">?";
  1073.   opname_tab[(int) ABS_EXPR] = "abs";
  1074.   opname_tab[(int) FFS_EXPR] = "ffs";
  1075.   opname_tab[(int) LSHIFT_EXPR] = "<<";
  1076.   opname_tab[(int) RSHIFT_EXPR] = ">>";
  1077.   opname_tab[(int) BIT_IOR_EXPR] = "|";
  1078.   opname_tab[(int) BIT_XOR_EXPR] = "^";
  1079.   opname_tab[(int) BIT_AND_EXPR] = "&";
  1080.   opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
  1081.   opname_tab[(int) BIT_NOT_EXPR] = "~";
  1082.   opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
  1083.   opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
  1084.   opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
  1085.   opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
  1086.   opname_tab[(int) TRUTH_NOT_EXPR] = "!";
  1087.   opname_tab[(int) LT_EXPR] = "<";
  1088.   opname_tab[(int) LE_EXPR] = "<=";
  1089.   opname_tab[(int) GT_EXPR] = ">";
  1090.   opname_tab[(int) GE_EXPR] = ">=";
  1091.   opname_tab[(int) EQ_EXPR] = "==";
  1092.   opname_tab[(int) NE_EXPR] = "!=";
  1093.   opname_tab[(int) IN_EXPR] = "in";
  1094.   opname_tab[(int) SET_LE_EXPR] = "subset";
  1095.   opname_tab[(int) CARD_EXPR] = "#";
  1096.   opname_tab[(int) RANGE_EXPR] = "..";
  1097.   opname_tab[(int) CONVERT_EXPR] = "(unary +)";
  1098.   opname_tab[(int) ADDR_EXPR] = "(unary &)";
  1099.   opname_tab[(int) PREDECREMENT_EXPR] = "--";
  1100.   opname_tab[(int) PREINCREMENT_EXPR] = "++";
  1101.   opname_tab[(int) POSTDECREMENT_EXPR] = "--";
  1102.   opname_tab[(int) POSTINCREMENT_EXPR] = "++";
  1103.   opname_tab[(int) COMPOUND_EXPR] = ",";
  1104.   assignop_tab[(int) NOP_EXPR] = "=";
  1105.   assignop_tab[(int) PLUS_EXPR] =  "+=";
  1106.   assignop_tab[(int) MINUS_EXPR] = "-=";
  1107.   assignop_tab[(int) MULT_EXPR] = "*=";
  1108.   assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
  1109.   assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
  1110.   assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
  1111.   assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
  1112.   assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
  1113.   assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
  1114.   assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
  1115.   assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
  1116.   assignop_tab[(int) MIN_EXPR] = "<?=";
  1117.   assignop_tab[(int) MAX_EXPR] = ">?=";
  1118.   assignop_tab[(int) LSHIFT_EXPR] = "<<=";
  1119.   assignop_tab[(int) RSHIFT_EXPR] = ">>=";
  1120.   assignop_tab[(int) BIT_IOR_EXPR] = "|=";
  1121.   assignop_tab[(int) BIT_XOR_EXPR] = "^=";
  1122.   assignop_tab[(int) BIT_AND_EXPR] = "&=";
  1123.  
  1124.   init_filename_times ();
  1125.  
  1126. #define UNSET_RESERVED_WORD(STRING) \
  1127.   do { is_reserved_word (STRING, sizeof (STRING) - 1)->name = ""; } while (0)
  1128.  
  1129.   if (! flag_handle_exceptions)
  1130.     {
  1131.       /* Easiest way to not reconize exception
  1132.      handling extenions...  */
  1133.       UNSET_RESERVED_WORD ("all");
  1134.       UNSET_RESERVED_WORD ("except");
  1135.       UNSET_RESERVED_WORD ("exception");
  1136.       UNSET_RESERVED_WORD ("raise");
  1137.       UNSET_RESERVED_WORD ("raises");
  1138.       UNSET_RESERVED_WORD ("reraise");
  1139.       UNSET_RESERVED_WORD ("try");
  1140.     }
  1141.   if (flag_no_asm)
  1142.     UNSET_RESERVED_WORD ("asm");
  1143.   if (flag_no_asm || flag_traditional)
  1144.     UNSET_RESERVED_WORD ("typeof");
  1145.   token_count = init_parse ();
  1146.   interface_unknown = 1;
  1147. }
  1148.  
  1149. void
  1150. reinit_parse_for_function ()
  1151. {
  1152.   current_base_init_list = NULL_TREE;
  1153.   current_member_init_list = NULL_TREE;
  1154. }
  1155.  
  1156. /* Functions and data structures for #pragma interface.
  1157.  
  1158.    `#pragma implementation' means that the main file being compiled
  1159.    is considered to implement (provide) the classes that appear in
  1160.    its main body.  I.e., if this is file "foo.cc", and class `bar'
  1161.    is defined in "foo.cc", then we say that "foo.cc implements bar".
  1162.  
  1163.    All main input files "implement" themselves automagically.
  1164.  
  1165.    `#pragma interface' means that unless this file (of the form "foo.h"
  1166.    is not presently being included by file "foo.cc", the
  1167.    CLASSTYPE_INTERFACE_ONLY bit gets set.  The effect is that none
  1168.    of the vtables nor any of the inline functions defined in foo.h
  1169.    will every be output.
  1170.  
  1171.    There are cases when we want to link files such as "defs.h" and
  1172.    "main.cc".  In this case, we give "defs.h" a `#pragma interface',
  1173.    and "main.cc" has `#pragma implementation "defs.h"'.  */
  1174.  
  1175. struct impl_files
  1176. {
  1177.   char *filename;
  1178.   struct impl_files *next;
  1179. };
  1180.  
  1181. static struct impl_files *impl_file_chain;
  1182.  
  1183. /* Helper function to load global variables with interface
  1184.    information.  */
  1185. static void
  1186. extract_interface_info ()
  1187. {
  1188.   tree fileinfo = get_time_identifier (input_filename);
  1189.   fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
  1190.   interface_only = TREE_INT_CST_LOW (fileinfo);
  1191.   interface_unknown = TREE_INT_CST_HIGH (fileinfo);
  1192. }
  1193.  
  1194. /* Return nonzero if S and T are not considered part of an
  1195.    INTERFACE/IMPLEMENTATION pair.  Otherwise, return 0.  */
  1196. static int
  1197. interface_strcmp (s)
  1198.      char *s;
  1199. {
  1200.   /* Set the interface/implementation bits for this scope.  */
  1201.   struct impl_files *ifiles;
  1202.   char *s1 = strrchr (s, '/');
  1203.   if (s1++ == 0)
  1204.     s1 = s;
  1205.   s = s1;
  1206.  
  1207.   for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
  1208.     {
  1209.       char *t1 = ifiles->filename;
  1210.       s1 = s;
  1211.  
  1212.       if (*s1 != *t1 || *s1 == 0)
  1213.     continue;
  1214.  
  1215.       while (*s1 == *t1 && *s1 != 0)
  1216.     s1++, t1++;
  1217.  
  1218.       /* A match.  */
  1219.       if (*s1 == *t1)
  1220.     return 0;
  1221.  
  1222.       /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc.  */
  1223.       if (strchr (s1, '.') || strchr (t1, '.'))
  1224.     continue;
  1225.  
  1226.       if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
  1227.     continue;
  1228.  
  1229.       /* A match.  */
  1230.       return 0;
  1231.     }
  1232.  
  1233.   /* No matches.  */
  1234.   return 1;
  1235. }
  1236.  
  1237. void
  1238. set_typedecl_interface_info (prev, vars)
  1239.      tree prev, vars;
  1240. {
  1241.   tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
  1242.   tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
  1243.   tree type = TREE_TYPE (vars);
  1244.  
  1245.   CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
  1246.     = interface_strcmp (DECL_SOURCE_FILE (vars));
  1247. }
  1248.  
  1249. void
  1250. set_vardecl_interface_info (prev, vars)
  1251.      tree prev, vars;
  1252. {
  1253. #if 0
  1254.   tree type = DECL_VPARENT (vars);
  1255. #else
  1256.   tree type = DECL_CONTEXT (vars);
  1257. #endif
  1258.  
  1259.   if (CLASSTYPE_INTERFACE_UNKNOWN (type) == 0)
  1260.     {
  1261.       if (CLASSTYPE_INTERFACE_ONLY (type))
  1262.     set_typedecl_interface_info (prev, TYPE_NAME (type));
  1263.       TREE_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
  1264.       TREE_PUBLIC (vars) = ! CLASSTYPE_INTERFACE_ONLY (type);
  1265.       CLASSTYPE_VTABLE_NEEDS_WRITING (type) |= TREE_PUBLIC (vars);
  1266.     }
  1267. }
  1268.  
  1269. /* Called from the top level: if there are any pending inlines to
  1270.    do, set up to process them now.  */
  1271. void
  1272. do_pending_inlines ()
  1273. {
  1274.   if (finput == finput1)
  1275.     {
  1276.       struct pending_inline *prev = 0, *tail;
  1277.       struct pending_inline *t =
  1278.     (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1279.                          sizeof (struct pending_inline));
  1280.  
  1281.       /* Record state we were in when we decided to process
  1282.      inline functions instead.  */
  1283.       t->next = pending_inlines;
  1284.       pending_inlines = t;
  1285.       t->lineno = lineno;
  1286.       t->filename = input_filename;
  1287.       t->fndecl = NULL_TREE;
  1288.       t->token = yychar;
  1289.       t->token_value = yylval.itype;
  1290.  
  1291.       /* Reverse the pending inline functions, since
  1292.      they were cons'd instead of appended.  */
  1293.  
  1294.       for (; t; t = tail)
  1295.     {
  1296.       tail = t->next;
  1297.       t->next = prev;
  1298.       prev = t;
  1299.     }
  1300.       pending_inlines = prev;
  1301.  
  1302.       /* Now start processing the first inline function.  */
  1303.       t = pending_inlines;
  1304.       pending_inlines = pending_inlines->next;
  1305.  
  1306. assert (finput2 != 0);
  1307.  
  1308.       finput = finput2;
  1309. #ifdef MASSCOMP
  1310.       setbuf (finput2, t->buf);
  1311.       finput2->_cnt = t->len-1;
  1312. #else
  1313. #if defined(i386) && !defined(sequent) && !defined(sun386)
  1314.       finput2->_ptr = finput2->_base = t->buf;
  1315.       _bufend(finput2) = t->buf + t->len;
  1316.       finput2->_flag = _IOFBF | _IOREAD;
  1317.       finput2->_cnt = t->len - 1;
  1318. #else
  1319. #ifndef hp9000s300
  1320. #ifdef USG_STDIO
  1321.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1322.       finput2->_cnt = t->len-1;
  1323. #else
  1324. #ifdef VMS
  1325.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1326.       (*finput2)->_cnt = t->len-1;
  1327. #else
  1328.       setbuffer (finput2, t->buf, t->len);
  1329.       finput2->_cnt = finput2->_bufsiz - 1;
  1330. #endif                /* VMS */
  1331. #endif                /* USG_STDIO */
  1332. #else
  1333.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1334.       finput2->_cnt = t->len-1;
  1335. #endif
  1336. #endif
  1337. #endif
  1338.       lineno = t->lineno;
  1339.       input_filename = t->filename;
  1340.       yychar = PRE_PARSED_FUNCTION_DECL;
  1341.       yylval.ttype = t->fndecl;
  1342.       if (flag_default_inline)
  1343.     TREE_INLINE (t->fndecl) = 1;
  1344.     }
  1345. }
  1346.  
  1347. /* Since inline methods can refer to text which has not yet been seen,
  1348.    we store the text of the method in a structure which is placed in the
  1349.    DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
  1350.    After parsing the body of the class definition, the FUNCTION_DECL's are
  1351.    scanned to see which ones have this field set.  Those are then digested
  1352.    one at a time.
  1353.  
  1354.    This function's FUNCTION_DECL will have a bit set in its common so
  1355.    that we know to watch out for it.  */
  1356.  
  1357. void
  1358. consume_string (this_obstack)
  1359.      register struct obstack *this_obstack;
  1360. {
  1361.   register char c;
  1362.   do
  1363.     {
  1364.       c = getc (finput);
  1365.       if (c == '\\')
  1366.     {
  1367.       obstack_1grow (this_obstack, c);
  1368.       c = getch ();
  1369.       obstack_1grow (this_obstack, c);
  1370.       continue;
  1371.     }
  1372.       if (c == '\n')
  1373.     {
  1374.       if (pedantic)
  1375.         warning ("ANSI C forbids newline in string constant");
  1376.       lineno++;
  1377.     }
  1378.       obstack_1grow (this_obstack, c);
  1379.     }
  1380.   while (c != '\"');
  1381. }
  1382.  
  1383. static int nextchar = -1;
  1384. static int nextyychar = -1;
  1385. static YYSTYPE nextyylval;
  1386. static tree nextlastiddecl;
  1387.  
  1388. /* Get input from stream.  When compiling under Cadillac,
  1389.    the bytes must be coaxed out via their read protocol.
  1390.    Otherwise, they come easily via standard input interface.  */
  1391. int
  1392. getch ()
  1393. {
  1394.   register int ch = getc (finput);
  1395.   return ch;
  1396. }
  1397.  
  1398. /* Return next non-whitespace input character, which may come
  1399.    from `finput', or from `nextchar'.  */
  1400. static int
  1401. yynextch ()
  1402. {
  1403.   int c;
  1404.  
  1405.   if (nextchar >= 0)
  1406.     {
  1407.       c = nextchar;
  1408.       nextchar = -1;
  1409.     }
  1410.   else c = getc (finput);
  1411.   return skip_white_space (c);
  1412. }
  1413.  
  1414. /* Unget character CH from the input stream.
  1415.    If RESCAN is non-zero, then we want to `see' this
  1416.    character as the next input token.  */
  1417. void
  1418. yyungetc (ch, rescan)
  1419.      int ch;
  1420.      int rescan;
  1421. {
  1422.   /* Unget a characater from the input stream.  */
  1423.   if (yychar == YYEMPTY || rescan == 0)
  1424.     ungetc (ch, finput);
  1425.   else
  1426.     {
  1427.       if (nextyychar >= 0)
  1428.     abort ();
  1429.       nextyychar = yychar;
  1430.       nextyylval = yylval;
  1431.       yychar = ch;
  1432.     }
  1433. }
  1434.  
  1435. void
  1436. reinit_parse_for_method (yychar, decl)
  1437.      int yychar;
  1438.      tree decl;
  1439. {
  1440.   register char c = 0;
  1441.   int blev = 1;
  1442.   tree fndecl = decl;
  1443.   int starting_lineno = lineno;
  1444.   char *starting_filename = input_filename;
  1445.   int len;
  1446.  
  1447.   if (yychar != '{')
  1448.     {
  1449.       if (yychar != ':' && yychar != RETURN)
  1450.     {
  1451.       yyerror ("parse error in method specification");
  1452.       yychar = '{';
  1453.     }
  1454.       obstack_1grow (&inline_text_obstack, yychar);
  1455.       while (c >= 0)
  1456.     {
  1457.       int this_lineno = lineno;
  1458.  
  1459.       c = yynextch ();
  1460.  
  1461.       /* Don't lose our cool if there are lots of comments.  */
  1462.       if (lineno - this_lineno)
  1463.         if (lineno - this_lineno == 1)
  1464.           obstack_1grow (&inline_text_obstack, '\n');
  1465.         else
  1466.           {
  1467.         char buf[12];
  1468.         sprintf (buf, "\n# %d \"", lineno);
  1469.         len = strlen (buf);
  1470.         obstack_grow (&inline_text_obstack, buf, len);
  1471.  
  1472.         len = strlen (input_filename);
  1473.         obstack_grow (&inline_text_obstack, input_filename, len);
  1474.         obstack_1grow (&inline_text_obstack, '\"');
  1475.         obstack_1grow (&inline_text_obstack, '\n');
  1476.           }
  1477.  
  1478.       /* strings must be read differently than text.  */
  1479.       if (c == '\"')
  1480.         {
  1481.           obstack_1grow (&inline_text_obstack, c);
  1482.           consume_string (&inline_text_obstack);
  1483.           c = yynextch ();
  1484.         }
  1485.       while (c > ' ')    /* ASCII dependent! */
  1486.         {
  1487.           obstack_1grow (&inline_text_obstack, c);
  1488.           if (c == '{') goto main_loop;
  1489.           if (c == '\"')
  1490.         consume_string (&inline_text_obstack);
  1491.           if (c == ';')
  1492.         {
  1493.           error ("function body for constructor missing");
  1494.           obstack_1grow (&inline_text_obstack, '{');
  1495.           obstack_1grow (&inline_text_obstack, '}');
  1496.           len += 2;
  1497.           goto done;
  1498.         }
  1499.           c = getch ();
  1500.         }
  1501.       if (c == '\n')
  1502.         lineno++;
  1503.       obstack_1grow (&inline_text_obstack, c);
  1504.     }
  1505.       if (c == EOF)
  1506.     {
  1507.       error_with_file_and_line (starting_filename,
  1508.                     starting_lineno,
  1509.                     "parse error in method specification");
  1510.     }      
  1511.     }
  1512.   else obstack_1grow (&inline_text_obstack, '{');
  1513.  
  1514.  main_loop:
  1515.   while (c >= 0)
  1516.     {
  1517.       int this_lineno = lineno;
  1518.  
  1519.       c = skip_white_space (getc (finput));
  1520.  
  1521.       /* Don't lose our cool if there are lots of comments.  */
  1522.       if (lineno - this_lineno)
  1523.     if (lineno - this_lineno == 1)
  1524.       obstack_1grow (&inline_text_obstack, '\n');
  1525.     else
  1526.       {
  1527.         char buf[12];
  1528.         sprintf (buf, "\n# %d \"", lineno);
  1529.         len = strlen (buf);
  1530.         obstack_grow (&inline_text_obstack, buf, len);
  1531.  
  1532.         len = strlen (input_filename);
  1533.         obstack_grow (&inline_text_obstack, input_filename, len);
  1534.         obstack_1grow (&inline_text_obstack, '\"');
  1535.         obstack_1grow (&inline_text_obstack, '\n');
  1536.       }
  1537.  
  1538.       while (c > ' ')
  1539.     {
  1540.       obstack_1grow (&inline_text_obstack, c);
  1541.       if (c == '{') blev++;
  1542.       else if (c == '}')
  1543.         {
  1544.           blev--;
  1545.           if (blev == 0)
  1546.         goto done;
  1547.         }
  1548.       else if (c == '\"')
  1549.         consume_string (&inline_text_obstack);
  1550.       c = getch ();
  1551.     }
  1552.       if (c == '\n')
  1553.     lineno++;
  1554.       obstack_1grow (&inline_text_obstack, c);
  1555.     }
  1556.  done:
  1557.   current_base_init_list = NULL_TREE;
  1558.   current_member_init_list = NULL_TREE;
  1559.  
  1560. #ifdef USG_STDIO
  1561.   len = obstack_object_size (&inline_text_obstack);
  1562.   /* If the buffer given to setvbuf is shorter than eight bytes long,
  1563.      setvbuf will (in violation of its man page) ignore the buffer
  1564.      and call malloc to get a bigger one.  */
  1565.   while (len < 8)
  1566.     {
  1567.       len++;
  1568.       obstack_1grow (&inline_text_obstack, ' ');
  1569.     }
  1570. #endif
  1571.  
  1572.   obstack_1grow (&inline_text_obstack, '\0');
  1573.   len = obstack_object_size (&inline_text_obstack);
  1574.  
  1575.   if (fndecl == void_type_node)
  1576.     {
  1577.       /* Happens when we get two declarations of the same
  1578.      function in the same scope.  */
  1579.       char *buf = obstack_base (&inline_text_obstack);
  1580.       obstack_free (&inline_text_obstack, buf);
  1581.       return;
  1582.     }
  1583.   else
  1584.     {
  1585.       struct pending_inline *t;
  1586.       char *buf = obstack_base (&inline_text_obstack);
  1587.  
  1588.       obstack_finish (&inline_text_obstack);
  1589.  
  1590.       t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1591.                            sizeof (struct pending_inline));
  1592.       t->buf = buf;
  1593.       t->len = len;
  1594.       t->lineno = starting_lineno;
  1595.       t->filename = starting_filename;
  1596.       t->token = YYEMPTY;
  1597.       DECL_PENDING_INLINE_INFO (fndecl) = t;
  1598.     }
  1599. }
  1600.  
  1601. /* Build a default function named NAME for type TYPE.
  1602.    KIND says what to build.  Currently only two kinds of default functions
  1603.    are recognized:
  1604.  
  1605.    When KIND == 0, build default X(X&) constructor.
  1606.    When KIND == 1, build default destructor.  */
  1607.  
  1608. tree
  1609. cons_up_default_function (type, name, kind)
  1610.      tree type, name;
  1611.      int kind;
  1612. {
  1613.   extern tree void_list_node;
  1614.   int len;
  1615.   tree fn, args;
  1616.   tree argtype;
  1617.  
  1618.   switch (kind)
  1619.     {
  1620.     case 0:
  1621.       /* Destructor.  */
  1622.       name = build_parse_node (BIT_NOT_EXPR, name);
  1623.       /* Fall through...  */
  1624.     case 2:
  1625.       /* Default constructor.  */
  1626.       args = void_list_node;
  1627.       break;
  1628.  
  1629.     case 3:
  1630.       type = build_type_variant (type, 1, 0);
  1631.       /* Fall through...  */
  1632.     case 1:
  1633.       argtype = build_reference_type (type);
  1634.       args = tree_cons (NULL_TREE,
  1635.             build_tree_list (hash_tree_chain (argtype, NULL_TREE),
  1636.                      get_identifier ("arg")),
  1637.             void_list_node);
  1638.       break;
  1639.  
  1640.     default:
  1641.       abort ();
  1642.     }
  1643.  
  1644.   fn = start_method (NULL_TREE,
  1645.              build_parse_node (CALL_EXPR, name, args, NULL_TREE),
  1646.              NULL_TREE);
  1647.   if (fn == void_type_node)
  1648.     return fn;
  1649.  
  1650.   obstack_1grow (&inline_text_obstack, '{');
  1651.   obstack_1grow (&inline_text_obstack, '}');
  1652. #ifdef USG_STDIO
  1653.   len = 2;
  1654.   while (len++ < 8)
  1655.     obstack_1grow (&inline_text_obstack, ' ');
  1656. #endif
  1657.  
  1658.   obstack_1grow (&inline_text_obstack, '\0');
  1659.   current_base_init_list = NULL_TREE;
  1660.   current_member_init_list = NULL_TREE;
  1661.  
  1662.   len = obstack_object_size (&inline_text_obstack);
  1663.  
  1664.   {
  1665.     struct pending_inline *t;
  1666.     char *buf = obstack_base (&inline_text_obstack);
  1667.  
  1668.     obstack_finish (&inline_text_obstack);
  1669.  
  1670.     t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1671.                          sizeof (struct pending_inline));
  1672.     t->buf = buf;
  1673.     t->len = len;
  1674.     t->lineno = lineno;
  1675.     t->filename = input_filename;
  1676.     t->token = YYEMPTY;
  1677.     DECL_PENDING_INLINE_INFO (fn) = t;
  1678.     /* We make this declaration private (static in the C sense).  */
  1679.     TREE_PUBLIC (fn) = 0;
  1680.   }
  1681.   finish_method (fn);
  1682.   DECL_COMPILER_GENERATED_P (fn) = 1;
  1683.   return fn;
  1684. }
  1685.  
  1686. /* Heuristic to tell whether the user is missing a semicolon
  1687.    after a struct or enum declaration.  Emit an error message
  1688.    if we know the user has blown it.  */
  1689. void
  1690. check_for_missing_semicolon (type)
  1691.      tree type;
  1692. {
  1693.   if (yychar < 0)
  1694.     yychar = yylex ();
  1695.  
  1696.   if (yychar > 255
  1697.       && yychar != IDENTIFIER
  1698.       && yychar != TYPENAME)
  1699.     {
  1700.       if (ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type))))
  1701.     error ("semicolon missing after %s declaration",
  1702.            TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
  1703.       else
  1704.     error ("semicolon missing after declaration of `%s'",
  1705.            TYPE_NAME_STRING (type));
  1706.       shadow_tag (build_tree_list (0, type));
  1707.     }
  1708.   /* Could probably also hack cases where class { ... } f (); appears.  */
  1709. }
  1710.  
  1711. void
  1712. note_got_semicolon (type)
  1713.      tree type;
  1714. {
  1715.   if (IS_AGGR_TYPE (type))
  1716.     CLASSTYPE_GOT_SEMICOLON (type) = 1;
  1717. }
  1718.  
  1719. /* If C is not whitespace, return C.
  1720.    Otherwise skip whitespace and return first nonwhite char read.  */
  1721.  
  1722. static int
  1723. skip_white_space (c)
  1724.      register int c;
  1725. {
  1726. #if 0
  1727.   register int inside;
  1728. #endif
  1729.  
  1730.   for (;;)
  1731.     {
  1732.       switch (c)
  1733.     {
  1734.       /* Don't recognize comments in cc1: all comments are removed by cpp,
  1735.          and cpp output can include / and * consecutively as operators.  */
  1736. #if 0
  1737.     case '/':
  1738.       c = getc (finput);
  1739.       if (c != '*' && c != '/')
  1740.         {
  1741.           ungetc (c, finput);
  1742.           return '/';
  1743.         }
  1744.  
  1745.       if (c == '/')
  1746.         {
  1747.           while (c != EOF)
  1748.         {
  1749.           c = getch ();
  1750.           if (c == '\n')
  1751.             {
  1752.               ungetc (c, finput);
  1753.               break;
  1754.             }
  1755.         }
  1756.           if (c == EOF)
  1757.         {
  1758.           error ("unterminated comment");
  1759.           return EOF;
  1760.         }
  1761.           c = getch ();
  1762.           break;
  1763.         }
  1764.  
  1765.       c = getch ();
  1766.  
  1767.       inside = 1;
  1768.       while (inside)
  1769.         {
  1770.           if (c == '*')
  1771.         {
  1772.           while (c == '*')
  1773.             c = getch ();
  1774.  
  1775.           if (c == '/')
  1776.             {
  1777.               inside = 0;
  1778.               c = getch ();
  1779.             }
  1780.         }
  1781.           else if (c == '\n')
  1782.         {
  1783.           lineno++;
  1784.           c = getch ();
  1785.         }
  1786.           else if (c == EOF)
  1787.         {
  1788.           error ("unterminated comment");
  1789.           break;
  1790.         }
  1791.           else
  1792.         c = getch ();
  1793.         }
  1794.  
  1795.       break;
  1796. #endif
  1797.  
  1798.     case '\n':
  1799.       c = check_newline ();
  1800.       break;
  1801.  
  1802.     case ' ':
  1803.     case '\t':
  1804.     case '\f':
  1805.     case '\r':
  1806.     case '\v':
  1807.     case '\b':
  1808.       do
  1809.         c = getc (finput);
  1810.       while (c == ' ' || c == '\t');
  1811.       break;
  1812.  
  1813.     case '\\':
  1814.       c = getch ();
  1815.       if (c == '\n')
  1816.         lineno++;
  1817.       else
  1818.         error ("stray '\\' in program");
  1819.       c = getch ();
  1820.       break;
  1821.  
  1822.     default:
  1823.       return (c);
  1824.     }
  1825.     }
  1826. }
  1827.  
  1828.  
  1829.  
  1830. /* Make the token buffer longer, preserving the data in it.
  1831.    P should point to just beyond the last valid character in the old buffer.
  1832.    The value we return is a pointer to the new buffer
  1833.    at a place corresponding to P.  */
  1834.  
  1835. static char *
  1836. extend_token_buffer (p)
  1837.      char *p;
  1838. {
  1839.   int offset = p - token_buffer;
  1840.  
  1841.   maxtoken = maxtoken * 2 + 10;
  1842.   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
  1843.  
  1844.   return token_buffer + offset;
  1845. }
  1846.  
  1847. #ifndef amigados
  1848. #ifndef MERGED
  1849. /* This includes code from write_segment, stolen from unexec.c */
  1850.  
  1851. void dump_data()
  1852. {
  1853.   int new;
  1854.   register caddr_t ptr, end;
  1855.   register int i, nwrite, ret;
  1856.   char buf[80];
  1857.   extern int errno;
  1858.   char zeros[128];
  1859.  
  1860.   extern int been_here_before, just_done_unexec, my_edata;
  1861.   extern char *dump_source_name;
  1862.   extern char *asm_file_name, previous_asm_file_name[];
  1863.   char dump_file_name[256];    /* Fixed-sized buffer -- sigh. */
  1864.   caddr_t end_of_data, end_of_heap;
  1865.   int data_size, token;
  1866.   register int c;
  1867.  
  1868.   bzero (zeros, sizeof zeros);
  1869.  
  1870.   /* Here we have just seen `#pragma dump '.
  1871.      The name to dump to, a string constant, may follow.  */
  1872.  
  1873.   do
  1874.     c = getch ();
  1875.   while (c == ' ' || c == '\t');
  1876.  
  1877.   /* If no argument, default to something like "dumped-cc1plus".  */
  1878.   if (c == '\n')
  1879.     {
  1880.       char *tmp;
  1881.       strcpy (dump_file_name, "dumped-");
  1882.       if (tmp = strrchr (dump_source_name, '/'))
  1883.     dump_source_name = tmp + 1;
  1884.       strcat (dump_file_name, dump_source_name);
  1885.     }
  1886.   else
  1887.     {
  1888.       ungetc (c, finput);
  1889.       token = yylex ();
  1890.       if (token != STRING
  1891.       || TREE_CODE (yylval.ttype) != STRING_CST)
  1892.     {
  1893.       error ("invalid #pragma dump");
  1894.       return;
  1895.     }
  1896.  
  1897.       strcpy (dump_file_name, TREE_STRING_POINTER (yylval.ttype));
  1898.     }
  1899.  
  1900.   been_here_before = 1;        /* Raise the flag! */
  1901.   strcpy(previous_asm_file_name, asm_file_name);
  1902.   printf("\nDumping %s to %s...\n", dump_source_name, dump_file_name);
  1903.  
  1904.   end_of_heap = (caddr_t)sbrk(0);
  1905.   end_of_data = (caddr_t)((int)(&my_edata)&~(getpagesize()-1));
  1906.   data_size = (int)(end_of_heap-end_of_data);
  1907.   printf("Data size = %d\n", data_size);
  1908.           
  1909.   new = creat (dump_file_name, 0666);
  1910.  
  1911.   ptr = end_of_data;
  1912.   end = end_of_heap;
  1913.  
  1914.   for (i = 0; ptr < end;)
  1915.     {
  1916.       /* distance to next multiple of 128.  */
  1917.       nwrite = (((int) ptr + 128) & -128) - (int) ptr;
  1918.       /* But not beyond specified end.  */
  1919.       if (nwrite > end - ptr) nwrite = end - ptr;
  1920.       ret = write (new, ptr, nwrite);
  1921.       /* If write gets a page fault, it means we reached
  1922.      a gap between the old text segment and the old data segment.
  1923.      This gap has probably been remapped into part of the text segment.
  1924.      So write zeros for it.  */
  1925.       if (ret == -1 && errno == EFAULT)
  1926.     write (new, zeros, nwrite);
  1927.       else if (nwrite != ret)
  1928.     {
  1929.       sprintf (buf,
  1930.            "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
  1931.            ptr, new, nwrite, ret, errno);
  1932.       perror (buf);
  1933.       return;
  1934.     }
  1935.       i += nwrite;
  1936.       ptr += nwrite;
  1937.     }
  1938.  
  1939.   close (new);
  1940.  
  1941.   just_done_unexec = 1;        /* Tell toplev not to output ending. */
  1942. }
  1943. #endif
  1944. #endif
  1945.  
  1946. static int
  1947. get_last_nonwhite_on_line ()
  1948. {
  1949.   register int c;
  1950.  
  1951.   /* Is this the last nonwhite stuff on the line?  */
  1952.   if (nextchar >= 0)
  1953.     c = nextchar, nextchar = -1;
  1954.   else
  1955.     c = getc (finput);
  1956.  
  1957.   while (c == ' ' || c == '\t')
  1958.     c = getc (finput);
  1959.   return c;
  1960. }
  1961.  
  1962. /* At the beginning of a line, increment the line number
  1963.    and process any #-directive on this line.
  1964.    If the line is a #-directive, read the entire line and return a newline.
  1965.    Otherwise, return the line's first non-whitespace character.  */
  1966.  
  1967. int
  1968. check_newline ()
  1969. {
  1970.   register int c;
  1971.   register int token;
  1972.  
  1973.   lineno++;
  1974.  
  1975.   /* Read first nonwhite char on the line.  */
  1976.  
  1977.   do
  1978.     c = getc (finput);
  1979.   while (c == ' ' || c == '\t');
  1980.  
  1981.   if (c != '#')
  1982.     {
  1983.       /* If not #, return it so caller will use it.  */
  1984.       return c;
  1985.     }
  1986.  
  1987.   /* Read first nonwhite char after the `#'.  */
  1988.  
  1989.   do
  1990.     c = getch ();
  1991.   while (c == ' ' || c == '\t');
  1992.  
  1993.   /* If a letter follows, then if the word here is `line', skip
  1994.      it and ignore it; otherwise, ignore the line, with an error
  1995.      if the word isn't `pragma'.  */
  1996.  
  1997.   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
  1998.     {
  1999.       if (c == 'p')
  2000.     {
  2001.       if (getch () == 'r'
  2002.           && getch () == 'a'
  2003.           && getch () == 'g'
  2004.           && getch () == 'm'
  2005.           && getch () == 'a')
  2006. /* Change by Bryan Boreham, Kewill, Sun Jul 23 15:53:24 1989.
  2007.    This whole section added to support dumping of
  2008.    compilations in the middle. */
  2009.         {
  2010.           /* Read first nonwhite char after the `#pragma'.  */
  2011.  
  2012.           do
  2013.         c = getch ();
  2014.           while (c == ' ' || c == '\t');
  2015.  
  2016. #ifndef MERGED
  2017.           /* See if it is "dump" */
  2018.  
  2019.           if (c == 'd'
  2020.           && getch () == 'u'
  2021.           && getch () == 'm'
  2022.           && getch () == 'p'
  2023.           && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2024.         {
  2025. #if defined(VMS) || defined(amigados)
  2026.             ;        /* Are you crazy? */
  2027. #else
  2028.           ungetc (c, finput);
  2029.           dump_data();
  2030.           longjmp (toplevel, 1);
  2031. #endif
  2032.         }
  2033.           else
  2034. #endif
  2035.         if (c == 'v'
  2036.                && getch () == 't'
  2037.                && getch () == 'a'
  2038.                && getch () == 'b'
  2039.                && getch () == 'l'
  2040.                && getch () == 'e'
  2041.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2042.         {
  2043.           extern tree pending_vtables;
  2044.  
  2045.           /* More follows: it must be a string constant (class name).  */
  2046.           token = yylex ();
  2047.           if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2048.             {
  2049.               error ("invalid #pragma vtable");
  2050.               goto skipline;
  2051.             }
  2052.           if (write_virtuals != 2)
  2053.             {
  2054.               warning ("use `+e2' option to enable #pragma vtable");
  2055.               goto skipline;
  2056.             }
  2057.           pending_vtables = perm_tree_cons (NULL_TREE, get_identifier (TREE_STRING_POINTER (yylval.ttype)), pending_vtables);
  2058.           if (nextchar < 0)
  2059.             nextchar = getch ();
  2060.           c = nextchar;
  2061.           if (c != '\n')
  2062.             warning ("trailing characters ignored");
  2063.         }
  2064.           else if (c == 'u'
  2065.                && getch () == 'n'
  2066.                && getch () == 'i'
  2067.                && getch () == 't'
  2068.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2069.         {
  2070.           /* More follows: it must be a string constant (unit name).  */
  2071.           token = yylex ();
  2072.           if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2073.             {
  2074.               error ("invalid #pragma unit");
  2075.               goto skipline;
  2076.             }
  2077.           current_unit_name = get_identifier (TREE_STRING_POINTER (yylval.ttype));
  2078.           current_unit_language = current_lang_name;
  2079.           if (nextchar < 0)
  2080.             nextchar = getch ();
  2081.           c = nextchar;
  2082.           if (c != '\n')
  2083.             warning ("trailing characters ignored");
  2084.         }
  2085.           else if (c == 'i')
  2086.         {
  2087.           tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
  2088.           c = getch ();
  2089.  
  2090.           if (c == 'n'
  2091.               && getch () == 't'
  2092.               && getch () == 'e'
  2093.               && getch () == 'r'
  2094.               && getch () == 'f'
  2095.               && getch () == 'a'
  2096.               && getch () == 'c'
  2097.               && getch () == 'e'
  2098.               && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2099.             {
  2100.               /* read to newline.  */
  2101.               while (c != '\n')
  2102.             c = getch ();
  2103.  
  2104.               write_virtuals = 3;
  2105.  
  2106.               if (impl_file_chain == 0)
  2107.             {
  2108.               char *filename;
  2109.               tree fi;
  2110.  
  2111.               /* If this is zero at this point, then we are
  2112.                  auto-implementing.  */
  2113.               if (main_input_filename == 0)
  2114.                 main_input_filename = input_filename;
  2115.  
  2116.               filename = strrchr (main_input_filename, '/');
  2117.               if (filename++ == 0)
  2118.                 filename = main_input_filename;
  2119.               fi = get_time_identifier (filename);
  2120.               fi = IDENTIFIER_CLASS_VALUE (fi);
  2121.               TREE_INT_CST_LOW (fi) = 0;
  2122.               TREE_INT_CST_LOW (fi) = 0;
  2123.               /* Get default.  */
  2124.               impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
  2125.               impl_file_chain->filename = filename;
  2126.               impl_file_chain->next = 0;
  2127.             }
  2128.  
  2129.               interface_only = interface_strcmp (input_filename);
  2130.               interface_unknown = 0;
  2131.               TREE_INT_CST_LOW (fileinfo) = interface_only;
  2132.               TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
  2133.             }
  2134.           else if (c == 'm'
  2135.                && getch () == 'p'
  2136.                && getch () == 'l'
  2137.                && getch () == 'e'
  2138.                && getch () == 'm'
  2139.                && getch () == 'e'
  2140.                && getch () == 'n'
  2141.                && getch () == 't'
  2142.                && getch () == 'a'
  2143.                && getch () == 't'
  2144.                && getch () == 'i'
  2145.                && getch () == 'o'
  2146.                && getch () == 'n'
  2147.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2148.             {
  2149.               char *main_filename = main_input_filename ? main_input_filename : input_filename;
  2150.               char *tmp;
  2151.  
  2152.               while (c == ' ' || c == '\t')
  2153.             c = getch ();
  2154.               if (c != '\n')
  2155.             {
  2156.               ungetc (c, finput);
  2157.               token = yylex ();
  2158.               if (token != STRING
  2159.                   || TREE_CODE (yylval.ttype) != STRING_CST)
  2160.                 {
  2161.                   error ("invalid `#pragma implementation'");
  2162.                   goto skipline;
  2163.                 }
  2164.               main_filename = TREE_STRING_POINTER (yylval.ttype);
  2165.             }
  2166.               tmp = strrchr (main_filename, '/');
  2167.               if (tmp++)
  2168.             main_filename = tmp;
  2169.  
  2170.               /* read to newline.  */
  2171.               while (c != '\n')
  2172.             c = getch ();
  2173.  
  2174.               if (write_virtuals == 3)
  2175.             {
  2176.               struct impl_files *ifiles = impl_file_chain;
  2177.               while (ifiles)
  2178.                 {
  2179.                   if (! strcmp (ifiles->filename, main_filename))
  2180.                 break;
  2181.                   ifiles = ifiles->next;
  2182.                 }
  2183.               if (ifiles == 0)
  2184.                 {
  2185.                   ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
  2186.                   ifiles->filename = main_filename;
  2187.                   ifiles->next = impl_file_chain;
  2188.                   impl_file_chain = ifiles;
  2189.                 }
  2190.             }
  2191.               else if (main_input_filename == input_filename
  2192.                    || ! strcmp (input_filename, main_filename))
  2193.             {
  2194.               write_virtuals = 3;
  2195.               if (impl_file_chain == 0)
  2196.                 {
  2197.                   impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
  2198.                   impl_file_chain->filename = main_filename;
  2199.                   impl_file_chain->next = 0;
  2200.                 }
  2201.             }
  2202.               else
  2203.             error ("`#pragma implementation' can only appear at top-level");
  2204.               interface_only = 0;
  2205.               interface_unknown = 0;
  2206.               TREE_INT_CST_LOW (fileinfo) = interface_only;
  2207.               TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
  2208.             }
  2209.         }
  2210.         }
  2211.       goto skipline;
  2212.     }
  2213.  
  2214.       else if (c == 'l')
  2215.     {
  2216.       if (getch () == 'i'
  2217.           && getch () == 'n'
  2218.           && getch () == 'e'
  2219.           && ((c = getch ()) == ' ' || c == '\t'))
  2220.         goto linenum;
  2221.     }
  2222.       else if (c == 'i')
  2223.     {
  2224.       if (getch () == 'd'
  2225.           && getch () == 'e'
  2226.           && getch () == 'n'
  2227.           && getch () == 't'
  2228.           && ((c = getch ()) == ' ' || c == '\t'))
  2229.         {
  2230.           /* Conditionally used.  */
  2231.               extern FILE *asm_out_file;
  2232.  
  2233.           if (pedantic)
  2234.         error ("ANSI C does not allow #ident");
  2235.  
  2236.           /* Here we have just seen `#ident '.
  2237.          A string constant should follow.  */
  2238.  
  2239.           while (c == ' ' || c == '\t')
  2240.         c = getch ();
  2241.  
  2242.           /* If no argument, ignore the line.  */
  2243.           if (c == '\n')
  2244.         return c;
  2245.  
  2246.           ungetc (c, finput);
  2247.           token = yylex ();
  2248.           if (token != STRING
  2249.           || TREE_CODE (yylval.ttype) != STRING_CST)
  2250.         {
  2251.           error ("invalid #ident");
  2252.           goto skipline;
  2253.         }
  2254.  
  2255. #ifdef ASM_OUTPUT_IDENT
  2256.           ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
  2257. #endif
  2258.  
  2259.           /* Skip the rest of this line.  */
  2260.           goto skipline;
  2261.         }
  2262.     }
  2263.       else if (c == 'n')
  2264.     {
  2265.       if (getch () == 'e'
  2266.           && getch () == 'w'
  2267.           && getch () == 'w'
  2268.           && getch () == 'o'
  2269.           && getch () == 'r'
  2270.           && getch () == 'l'
  2271.           && getch () == 'd'
  2272.           && ((c = getch ()) == ' ' || c == '\t'))
  2273.         {
  2274.           /* Used to test incremental compilation.  */
  2275.           sorry ("#pragma newworld");
  2276.           goto skipline;
  2277.         }
  2278.     }
  2279.       error ("undefined or invalid # directive");
  2280.       goto skipline;
  2281.     }
  2282.  
  2283. linenum:
  2284.   /* Here we have either `#line' or `# <nonletter>'.
  2285.      In either case, it should be a line number; a digit should follow.  */
  2286.  
  2287.   while (c == ' ' || c == '\t')
  2288.     c = getch ();
  2289.  
  2290.   /* If the # is the only nonwhite char on the line,
  2291.      just ignore it.  Check the new newline.  */
  2292.   if (c == '\n')
  2293.     return c;
  2294.  
  2295.   /* Something follows the #; read a token.  */
  2296.  
  2297.   ungetc (c, finput);
  2298.   token = yylex ();
  2299.  
  2300.   if (token == CONSTANT
  2301.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  2302.     {
  2303.       int old_lineno = lineno;
  2304.       /* subtract one, because it is the following line that
  2305.      gets the specified number */
  2306.  
  2307.       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
  2308.       c = get_last_nonwhite_on_line ();
  2309.       if (c == '\n')
  2310.     {
  2311.       /* No more: store the line number and check following line.  */
  2312.       lineno = l;
  2313.       return c;
  2314.     }
  2315.       ungetc (c, finput);
  2316.  
  2317.       /* More follows: it must be a string constant (filename).  */
  2318.  
  2319.       token = yylex ();
  2320.       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2321.     {
  2322.       error ("invalid #line");
  2323.       goto skipline;
  2324.     }
  2325.  
  2326.       /* Changing files again.  This means currently collected time
  2327.      is charged against header time, and body time starts back
  2328.      at 0.  */
  2329.       if (flag_detailed_statistics)
  2330.     {
  2331.       int this_time = my_gettime ();
  2332.       tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
  2333.       header_time += this_time - body_time;
  2334.       TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
  2335.         += this_time - body_time;
  2336.       this_filename_time = time_identifier;
  2337.       body_time = this_time;
  2338.     }
  2339.  
  2340.       input_filename
  2341.     = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
  2342.       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
  2343.       lineno = l;
  2344. #ifdef FIELD_XREF
  2345.       FIELD_xref_file(input_filename);
  2346. #endif
  2347.  
  2348.       if (main_input_filename == 0)
  2349.     {
  2350.       extern int been_here_before;
  2351.       struct impl_files *ifiles = impl_file_chain;
  2352.  
  2353.       if (ifiles)
  2354.         {
  2355.           while (ifiles->next)
  2356.         ifiles = ifiles->next;
  2357.           ifiles->filename = (char *)strrchr (input_filename, '/');
  2358.           if (ifiles->filename++ == 0)
  2359.         ifiles->filename = input_filename;
  2360.         }
  2361.  
  2362.       main_input_filename = input_filename;
  2363.       if (write_virtuals == 3)
  2364.         walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
  2365.     }
  2366.  
  2367.       extract_interface_info ();
  2368.  
  2369.       c = get_last_nonwhite_on_line ();
  2370.       if (c == '\n')
  2371.     return c;
  2372.       ungetc (c, finput);
  2373.  
  2374.       token = yylex ();
  2375.  
  2376.       /* `1' after file name means entering new file.
  2377.      `2' after file name means just left a file.  */
  2378.  
  2379.       if (token == CONSTANT
  2380.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  2381.     {
  2382.       if (TREE_INT_CST_LOW (yylval.ttype) == 1)
  2383.         {
  2384.           struct file_stack *p
  2385.         = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  2386.           input_file_stack->line = old_lineno;
  2387.           p->next = input_file_stack;
  2388.           p->name = input_filename;
  2389.           input_file_stack = p;
  2390.           input_file_stack_tick++;
  2391.         }
  2392.       else if (input_file_stack->next)
  2393.         {
  2394.           struct file_stack *p = input_file_stack;
  2395.  
  2396.           input_file_stack = p->next;
  2397.           free (p);
  2398.           input_file_stack_tick++;
  2399.         }
  2400.       else
  2401.         error ("#-lines for entering and leaving files don't match");
  2402.     }
  2403.       /* If NEXTCHAR is not end of line, we don't care what it is.  */
  2404.       if (nextchar == '\n')
  2405.     return '\n';
  2406.     }
  2407.   else
  2408.     error ("invalid #-line");
  2409.  
  2410.   /* skip the rest of this line.  */
  2411.  skipline:
  2412.   if (c == '\n')
  2413.     return c;
  2414.   while ((c = getch ()) != EOF && c != '\n');
  2415.   return c;
  2416. }
  2417.  
  2418. #if 0
  2419. #define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0)
  2420. #define isdigit(char) (char >= '0' && char <= '9')
  2421. #else
  2422. #include <ctype.h>
  2423. #endif
  2424.  
  2425. #define ENDFILE -1  /* token that represents end-of-file */
  2426.  
  2427. static int
  2428. readescape ()
  2429. {
  2430.   register int c = getc (finput);
  2431.   register int count, code;
  2432.   int firstdig;
  2433.  
  2434.   switch (c)
  2435.     {
  2436.     case 'x':
  2437.       code = 0;
  2438.       count = 0;
  2439.       while (1)
  2440.     {
  2441.       c = getch ();
  2442.       if (! isxdigit (c))
  2443.         {
  2444.           ungetc (c, finput);
  2445.           break;
  2446.         }
  2447.       code *= 16;
  2448.       if (c >= 'a' && c <= 'f')
  2449.         code += c - 'a' + 10;
  2450.       if (c >= 'A' && c <= 'F')
  2451.         code += c - 'A' + 10;
  2452.       if (c >= '0' && c <= '9')
  2453.         code += c - '0';
  2454.       if (count == 0)
  2455.         firstdig = code;
  2456.       count++;
  2457.     }
  2458.       if (count == 0)
  2459.     error ("\\x used with no following hex digits");
  2460.       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
  2461.            || ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
  2462.            <= firstdig))
  2463.     warning ("hex escape out of range");
  2464.       return code;
  2465.  
  2466.     case '0':  case '1':  case '2':  case '3':  case '4':
  2467.     case '5':  case '6':  case '7':
  2468.       code = 0;
  2469.       count = 0;
  2470.       while ((c <= '7') && (c >= '0') && (count++ < 3))
  2471.     {
  2472.       code = (code * 8) + (c - '0');
  2473.       c = getch ();
  2474.     }
  2475.       ungetc (c, finput);
  2476.       return code;
  2477.  
  2478.     case '\\': case '\'': case '"':
  2479.       return c;
  2480.  
  2481.     case '\n':
  2482.       lineno++;
  2483.       return -1;
  2484.  
  2485.     case 'n':
  2486.       return TARGET_NEWLINE;
  2487.  
  2488.     case 't':
  2489.       return TARGET_TAB;
  2490.  
  2491.     case 'r':
  2492.       return TARGET_CR;
  2493.  
  2494.     case 'f':
  2495.       return TARGET_FF;
  2496.  
  2497.     case 'b':
  2498.       return TARGET_BS;
  2499.  
  2500.     case 'a':
  2501.       return TARGET_BELL;
  2502.  
  2503.     case 'v':
  2504.       return TARGET_VT;
  2505.  
  2506.     case 'E':
  2507.       return 033;
  2508.  
  2509.     case '?':
  2510.       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
  2511.     case '(':
  2512.     case '{':
  2513.     case '[':
  2514.       return c;
  2515.     }
  2516.   if (c >= 040 && c <= 0177)
  2517.     warning ("unknown escape sequence `\\%c'", c);
  2518.   else
  2519.     warning ("unknown escape sequence: `\\' followed by char code 0x%x", c);
  2520.   return c;
  2521. }
  2522.  
  2523. /* Value is 1 if we should try to make the next identifier look like a
  2524.    typename (when it may be a local variable or a class variable).
  2525.    Value is 0 if we treat this name in a default fashion.
  2526.    Value is -1 if we must not see a type name.  */
  2527. int looking_for_typename = 0;
  2528.  
  2529. void
  2530. dont_see_typename ()
  2531. {
  2532.   looking_for_typename = -1;
  2533.   if (yychar == TYPENAME)
  2534.     {
  2535.       yychar = IDENTIFIER;
  2536.       lastiddecl = 0;
  2537.     }
  2538. }
  2539.  
  2540. void
  2541. see_typename ()
  2542. {
  2543.   looking_for_typename = 0;
  2544.   if (yychar == IDENTIFIER)
  2545.     {
  2546.       lastiddecl = lookup_name (yylval.ttype);
  2547.       if (lastiddecl == 0 && flag_labels_ok)
  2548.     lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
  2549.       else if (lastiddecl != 0
  2550.            && TREE_CODE (lastiddecl) == TYPE_DECL)
  2551.     yychar = TYPENAME;
  2552.     }
  2553. }
  2554.  
  2555. tree do_identifier (token)
  2556.      register tree token;
  2557. {
  2558.   register tree id = lastiddecl;
  2559.  
  2560.   if (yychar == YYEMPTY)
  2561.     yychar = yylex ();
  2562.   /* Scope class declarations before global
  2563.      declarations.  */
  2564.   if (id == IDENTIFIER_GLOBAL_VALUE (token)
  2565.       && current_class_type != 0
  2566.       && TYPE_SIZE (current_class_type) == 0)
  2567.     {
  2568.       /* Could be from one of the base classes.  */
  2569.       tree field = lookup_field (current_class_type, token, 1);
  2570.       if (field == 0)
  2571.     ;
  2572.       else if (field == error_mark_node)
  2573.     /* We have already generated the error message.
  2574.        But we still want to return this value.  */
  2575.     id = lookup_field (current_class_type, token, 0);
  2576.       else if (TREE_CODE (field) == VAR_DECL
  2577.            || TREE_CODE (field) == CONST_DECL)
  2578.     id = field;
  2579.       else if (TREE_CODE (field) != FIELD_DECL)
  2580.     abort ();
  2581.       else
  2582.     {
  2583.       error_with_decl (field, "invalid use of member `%s' from base class `%s'",
  2584.                TYPE_NAME_STRING (DECL_FIELD_CONTEXT (field)));
  2585.       id = error_mark_node;
  2586.       return id;
  2587.     }
  2588.     }
  2589.  
  2590.   if (!id || id == error_mark_node)
  2591.     {
  2592.       if (yychar == '(' || yychar == LEFT_RIGHT)
  2593.     {
  2594.       id = implicitly_declare (token);
  2595.       assemble_external (id);
  2596.       TREE_USED (id) = 1;
  2597.     }
  2598.       else if (current_function_decl == 0)
  2599.     {
  2600.       error ("`%s' undeclared, outside of functions",
  2601.          IDENTIFIER_POINTER (token));
  2602.       id = error_mark_node;
  2603.     }
  2604.       else
  2605.     {
  2606.       if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node
  2607.           || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
  2608.         {
  2609.           extern int undeclared_variable_notice;
  2610.  
  2611.           error ("`%s' undeclared (first use this function)",
  2612.              IDENTIFIER_POINTER (token));
  2613.  
  2614.           if (! undeclared_variable_notice)
  2615.         {
  2616.           error ("(Each undeclared identifier is reported only once");
  2617.           error ("for each function it appears in.)");
  2618.           undeclared_variable_notice = 1;
  2619.         }
  2620.         }
  2621.       id = error_mark_node;
  2622.       /* Prevent repeated error messages.  */
  2623.       IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node;
  2624.       SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
  2625.     }
  2626.     }
  2627.   /* TREE_USED is set in `hack_identifier'.  */
  2628.   if (TREE_CODE (id) == CONST_DECL)
  2629.     {
  2630.       if (IDENTIFIER_CLASS_VALUE (token) == id)
  2631.     {
  2632.       /* Check visibility.  */
  2633.       enum visibility_type visibility
  2634.         = compute_visibility (CLASSTYPE_AS_LIST (current_class_type), id);
  2635.       if (visibility == visibility_private)
  2636.         error_with_decl (id, "enum `%s' is private");
  2637.       /* protected is OK, since it's an enum of `this'.  */
  2638.     }
  2639.       id = DECL_INITIAL (id);
  2640.     }
  2641.   else id = hack_identifier (id, token, yychar);
  2642.   return id;
  2643. }
  2644.  
  2645. int
  2646. yylex ()
  2647. {
  2648.   tree tmp;
  2649.   register int c;
  2650.   register int value;
  2651.   int wide_flag = 0;
  2652.   int dollar_seen = 0;
  2653.  
  2654.  relex:
  2655.   if (nextyychar >= 0)
  2656.     {
  2657.       value = nextyychar;
  2658.       yylval = nextyylval;
  2659.       lastiddecl = nextlastiddecl;
  2660.       nextyychar = -1;
  2661.       if (value == IDENTIFIER)
  2662.     {
  2663.       tmp = yylval.ttype;
  2664.       goto resume_identifier_processing;
  2665.     }
  2666.       goto done;
  2667.     }
  2668.   if (nextchar >= 0)
  2669.     c = nextchar, nextchar = -1;
  2670.   else
  2671.     c = getc (finput);
  2672.  
  2673.   /* Effectively do c = skip_white_space (c)
  2674.      but do it faster in the usual cases.  */
  2675.   while (1)
  2676.     switch (c)
  2677.       {
  2678.       case ' ':
  2679.       case '\t':
  2680.       case '\f':
  2681.       case '\r':
  2682.       case '\v':
  2683.       case '\b':
  2684.     c = getc (finput);
  2685.     break;
  2686.  
  2687.       case '\n':
  2688.       case '/':
  2689.       case '\\':
  2690.     c = skip_white_space (c);
  2691.       default:
  2692.     goto found_nonwhite;
  2693.       }
  2694.  found_nonwhite:
  2695.  
  2696.   token_buffer[0] = c;
  2697.   token_buffer[1] = 0;
  2698.  
  2699. /*  yylloc.first_line = lineno; */
  2700.  
  2701.   switch (c)
  2702.     {
  2703.     case EOF:
  2704.       token_buffer[0] = '\0';
  2705.       if (pending_inlines)
  2706.     {
  2707.       struct pending_inline *t;
  2708.  
  2709.       t = pending_inlines;
  2710. #ifdef DO_METHODS_THE_OLD_WAY
  2711.       yylval.itype = t->token_value;
  2712.       value = t->token;
  2713. #else
  2714.       if (t->fndecl == 0)
  2715.         {
  2716.           yylval.itype = t->token_value;
  2717.           value = t->token;
  2718.         }
  2719.       else
  2720.         {
  2721.           yylval.ttype = t->fndecl;
  2722.           value = PRE_PARSED_FUNCTION_DECL;
  2723.         }
  2724. #endif
  2725.  
  2726.       lineno = t->lineno;
  2727. /*        yylloc.first_line = lineno; */
  2728.       input_filename = t->filename;
  2729.  
  2730.       if (t->next)
  2731.         {
  2732. assert (finput2 != 00);
  2733.  
  2734.           /* The buffer we used will be freed at the
  2735.          end of this function.  */
  2736.           pending_inlines = pending_inlines->next;
  2737. #ifdef MASSCOMP
  2738.           setbuf (finput2, t->buf);
  2739.           finput2->_cnt = t->len-1;
  2740. #else
  2741. #if defined(i386) && !defined(sequent) && !defined(sun386)
  2742.           finput2->_ptr = finput2->_base = t->buf;
  2743.           _bufend(finput2) = t->buf + t->len;
  2744.           finput2->_flag = _IOFBF | _IOREAD;
  2745.           finput2->_cnt = t->len - 1;
  2746. #else
  2747. #ifndef hp9000s300
  2748. #ifdef USG_STDIO
  2749.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2750.                  finput2->_cnt = t->len-1;
  2751. #else
  2752. #ifdef VMS
  2753.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2754.                  (*finput2)->_cnt = t->len-1;
  2755. #else
  2756.             setbuffer (finput2, t->buf, t->len);
  2757.             finput2->_cnt = finput2->_bufsiz - 1;
  2758. #endif                /* VMS */
  2759. #endif                /* USG_STDIO */
  2760. #else
  2761.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2762.                  finput2->_cnt = t->len-1;
  2763. #endif
  2764. #endif
  2765. #endif
  2766.         }
  2767.       else
  2768.         {
  2769.           pending_inlines = NULL;
  2770.           finput = finput1;
  2771.           obstack_free (&inline_text_obstack, inline_text_firstobj);
  2772.         }
  2773.       /* The space used by T will be freed after all inline
  2774.          functions have been processed.  */
  2775.       if (value <= 0)
  2776.         goto relex;
  2777.       else
  2778.         goto done;
  2779.     }
  2780.       end_of_file = 1;
  2781.       value = ENDFILE;
  2782.       break;
  2783.  
  2784.     case '$':
  2785.       if (dollars_in_ident)
  2786.     {
  2787.       dollar_seen = 1;
  2788.       goto letter;
  2789.     }
  2790.       value = '$';
  2791.       goto done;
  2792.  
  2793.     case 'L':
  2794.       /* Capital L may start a wide-string or wide-character constant.  */
  2795.       {
  2796.     register int c = getch ();
  2797.     if (c == '\'')
  2798.       {
  2799.         wide_flag = 1;
  2800.         goto char_constant;
  2801.       }
  2802.     if (c == '"')
  2803.       {
  2804.         wide_flag = 1;
  2805.         goto string_constant;
  2806.       }
  2807.     ungetc (c, finput);
  2808.       }
  2809.  
  2810.     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
  2811.     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
  2812.     case 'K':          case 'M':  case 'N':  case 'O':
  2813.     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
  2814.     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
  2815.     case 'Z':
  2816.     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
  2817.     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
  2818.     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
  2819.     case 'p':  case 'q':  case 'r':  case 's':  case 't':
  2820.     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
  2821.     case 'z':
  2822.     case '_':
  2823.     letter:
  2824.       {
  2825.     register char *p;
  2826.  
  2827.     p = token_buffer;
  2828.     while (isalnum(c) || (c == '_') || c == '$')
  2829.       {
  2830.         if (p >= token_buffer + maxtoken)
  2831.           p = extend_token_buffer (p);
  2832.         if (c == '$' && ! dollars_in_ident)
  2833.           break;
  2834.  
  2835.         *p++ = c;
  2836.         c = getc (finput);
  2837.       }
  2838.  
  2839.     *p = 0;
  2840.     nextchar = c;
  2841.  
  2842.     value = IDENTIFIER;
  2843.     yylval.itype = 0;
  2844.  
  2845.       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
  2846.  
  2847.     {
  2848.       register struct resword *ptr;
  2849.  
  2850.       if (ptr = is_reserved_word (token_buffer, p - token_buffer))
  2851.         {
  2852.           if (current_lang_name != lang_name_cplusplus)
  2853.         {
  2854.           if (ptr->rid != 0
  2855.               && (ptr->rid == RID_CLASS
  2856.               || ptr->rid == RID_FRIEND
  2857.               || ptr->rid == RID_VIRTUAL
  2858.               || (flag_no_asm && ptr->rid == RID_INLINE)))
  2859.             {
  2860.               ptr = 0;
  2861.               goto not_reserved_word_after_all;
  2862.             }
  2863.           if (flag_traditional
  2864.               && ((int) ptr->token == TYPEOF
  2865.               || ptr->rid == RID_SIGNED
  2866.               || ptr->rid == RID_INLINE))
  2867.             {
  2868.               ptr = 0;
  2869.               goto not_reserved_word_after_all;
  2870.             }  
  2871.         }
  2872.           if (ptr->rid)
  2873.         {
  2874.           tree old_ttype = ridpointers[(int) ptr->rid];
  2875.  
  2876.           /* If this provides a type for us, then revert lexical
  2877.              state to standard state.  */
  2878.           if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
  2879.               && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
  2880.               && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
  2881.             looking_for_typename = 0;
  2882.  
  2883.           /* Check if this is a language-type declaration.
  2884.              Just glimpse the next non-white character.  */
  2885.           nextchar = skip_white_space (nextchar);
  2886.           if (nextchar == '"')
  2887.             {
  2888.               /* We are looking at a string.  Complain
  2889.              if the token before the string is no `extern'.
  2890.              
  2891.              Could cheat some memory by placing this string
  2892.              on the temporary_, instead of the saveable_
  2893.              obstack.  */
  2894.  
  2895.               if (ptr->rid != RID_EXTERN)
  2896.             error ("invalid modifier `%s' for language string",
  2897.                    ptr->name);
  2898.               yylex ();
  2899.               value = EXTERN_LANG_STRING;
  2900.               yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
  2901.               break;
  2902.             }
  2903.           yylval.ttype = old_ttype;
  2904.         }
  2905.           value = (int) ptr->token;
  2906.         }
  2907.       not_reserved_word_after_all:
  2908.       ;
  2909.     }
  2910.  
  2911.     /* If we did not find a keyword, look for an identifier
  2912.        (or a typename).  */
  2913.  
  2914. #ifdef FIELD_XREF
  2915.     if (value == IDENTIFIER || value == TYPESPEC)
  2916.       FIELD_xref_ref(current_function_decl,token_buffer);
  2917. #endif
  2918.     if (value == IDENTIFIER)
  2919.       {
  2920.         tmp = get_identifier (token_buffer);
  2921. #ifndef VMS
  2922.         /* Make sure that user does not collide with our internal
  2923.            naming scheme.  */
  2924.         if (JOINER == '$'
  2925.         && dollar_seen
  2926.         && (THIS_NAME_P (tmp)
  2927.             || VPTR_NAME_P (tmp)
  2928.             || DESTRUCTOR_NAME_P (tmp)
  2929.             || WRAPPER_OR_ANTI_WRAPPER_NAME_P (tmp)
  2930.             || OPERATOR_NAME_P (tmp)
  2931.             || VTABLE_NAME_P (tmp)
  2932.             || OPERATOR_TYPENAME_P (tmp)
  2933.             || TEMP_NAME_P (tmp)
  2934.             || ANON_AGGRNAME_P (tmp)
  2935.             || ANON_PARMNAME_P (tmp)))
  2936.           warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
  2937.                token_buffer);
  2938. #endif
  2939.  
  2940.         /* Come into here if we must reprocess an identifier.  */
  2941.       resume_identifier_processing:
  2942.  
  2943.         if (looking_for_typename == 1
  2944.         && TREE_TYPE (tmp) != 0)
  2945.           lastiddecl = TREE_TYPE (tmp);
  2946.         else lastiddecl = lookup_name (tmp);
  2947.  
  2948.         if (lastiddecl && TREE_CODE (lastiddecl) == TYPE_DECL
  2949.         && looking_for_typename >= 0)
  2950.           {
  2951.         /* This call could blow away yylval.  */
  2952.  
  2953.         c = skip_white_space (nextchar);
  2954.         if (c == ':')
  2955.           {
  2956.             c = getch ();
  2957.             if (c == ':')
  2958.               {
  2959.             nextchar = -1;
  2960.             value = TYPENAME_SCOPE;
  2961.               }
  2962.             else
  2963.               {
  2964.             nextchar = c;
  2965.             value = TYPENAME_COLON;
  2966.               }
  2967.           }
  2968.         else if (c == '.'
  2969.              && current_function_decl == NULL_TREE
  2970.              && current_class_type == NULL_TREE)
  2971.           {
  2972.             c = getch ();
  2973.             if (c == '.')
  2974.               {
  2975.             nextchar = -1;
  2976.             c = getch ();
  2977.             if (c != '.')
  2978.               error ("missing '.' in `...'");
  2979.             value = TYPENAME_ELLIPSIS;
  2980.             tmp = build_tree_list (NULL_TREE, build_tree_list (TREE_TYPE (lastiddecl), NULL_TREE));
  2981.               }
  2982.             else
  2983.               {
  2984.             nextchar = c;
  2985.             warning ("use of obsolete scope operator `.'; use `::' instead");
  2986.             value = TYPENAME_SCOPE;
  2987.               }
  2988.             looking_for_typename = 0;
  2989.           }
  2990.         else
  2991.           {
  2992.             nextchar = c;
  2993.             value = TYPENAME;
  2994.             if (looking_for_typename == 1)
  2995.               {
  2996.             looking_for_typename = 0;
  2997. #if 0
  2998.             yylval.ttype = TREE_TYPE (lastiddecl);
  2999.             break;
  3000. #endif
  3001.               }
  3002.           }
  3003.           }
  3004.         else if (lastiddecl == 0 && flag_labels_ok)
  3005.           lastiddecl = IDENTIFIER_LABEL_VALUE (tmp);
  3006.  
  3007.         yylval.ttype = tmp;
  3008.       }
  3009.     if (value == NEW && ! global_bindings_p ())
  3010.       {
  3011.         looking_for_typename = 1;
  3012.         value = NEW;
  3013.         goto done;
  3014.       }
  3015.       }
  3016.       break;
  3017.  
  3018.     case '0':  case '1':  case '2':  case '3':  case '4':
  3019.     case '5':  case '6':  case '7':  case '8':  case '9':
  3020.     case '.':
  3021.       {
  3022.     register char *p;
  3023.     int base = 10;
  3024.     int count = 0;
  3025.     int largest_digit = 0;
  3026.     int numdigits = 0;
  3027.     /* for multi-precision arithmetic,
  3028.        we store only 8 live bits in each short,
  3029.        giving us 64 bits of reliable precision */
  3030.     short shorts[8];
  3031.  
  3032.     enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
  3033.       = NOT_FLOAT;
  3034.  
  3035.     p = token_buffer;
  3036.     *p++ = c;
  3037.  
  3038.     /* Optimize for most frequent case.  */
  3039.     if (c == '0' || c == '1')
  3040.       {
  3041.         register int c1 = getch ();
  3042.         if (! isalnum (c1) && c1 != '.')
  3043.           {
  3044.         /* Terminate string.  */
  3045.         *p = 0;
  3046.         if (c == '0')
  3047.           yylval.ttype = integer_zero_node;
  3048.         else
  3049.           yylval.ttype = integer_one_node;
  3050.         nextchar = c1;
  3051.         value = CONSTANT;
  3052.         goto done;
  3053.           }
  3054.         ungetc (c1, finput);
  3055.       }
  3056.  
  3057.     for (count = 0; count < 8; count++)
  3058.       shorts[count] = 0;
  3059.  
  3060.     if (c == '0')
  3061.       {
  3062.         *p++ = (c = getch ());
  3063.         if ((c == 'x') || (c == 'X'))
  3064.           {
  3065.         base = 16;
  3066.         *p++ = (c = getch ());
  3067.           }
  3068.         else
  3069.           {
  3070.         base = 8;
  3071.         numdigits++;
  3072.           }
  3073.       }
  3074.  
  3075.     /* Read all the digits-and-decimal-points.  */
  3076.  
  3077.     while (c == '.'
  3078.            || (isalnum (c) && (c != 'l') && (c != 'L')
  3079.            && (c != 'u') && (c != 'U')
  3080.            && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
  3081.       {
  3082.         if (c == '.')
  3083.           {
  3084.         if (base == 16)
  3085.           error ("floating constant may not be in radix 16");
  3086.         if (floatflag == AFTER_POINT)
  3087.           {
  3088.             error ("malformed floating constant");
  3089.             floatflag = TOO_MANY_POINTS;
  3090.           }
  3091.         else
  3092.           floatflag = AFTER_POINT;
  3093.  
  3094.         base = 10;
  3095.         *p++ = c = getch ();
  3096.         /* Accept '.' as the start of a floating-point number
  3097.            only when it is followed by a digit.
  3098.            Otherwise, unread the following non-digit
  3099.            and use the '.' as a structural token.  */
  3100.         if (p == token_buffer + 2 && !isdigit (c))
  3101.           {
  3102.             if (c == '.')
  3103.               {
  3104.             c = getch ();
  3105.             if (c == '.')
  3106.               {
  3107.                 *p++ = '.';
  3108.                 *p = '\0';
  3109.                 value = ELLIPSIS;
  3110.                 goto done;
  3111.               }
  3112.             nextchar = c;
  3113.             token_buffer[2] = '\0';
  3114.             value = RANGE;
  3115.             goto done;
  3116.               }
  3117.             nextchar = c;
  3118.             token_buffer[1] = '\0';
  3119.             value = '.';
  3120.             goto done;
  3121.           }
  3122.           }
  3123.         else
  3124.           {
  3125.         /* It is not a decimal point.
  3126.            It should be a digit (perhaps a hex digit).  */
  3127.  
  3128.         if (isdigit (c))
  3129.           {
  3130.             c = c - '0';
  3131.           }
  3132.         else if (base <= 10)
  3133.           {
  3134.             if ((c&~040) == 'E')
  3135.               {
  3136.             base = 10;
  3137.             floatflag = AFTER_POINT;
  3138.             break;   /* start of exponent */
  3139.               }
  3140.             error ("nondigits in number and not hexadecimal");
  3141.             c = 0;
  3142.           }
  3143.         else if (c >= 'a')
  3144.           {
  3145.             c = c - 'a' + 10;
  3146.           }
  3147.         else
  3148.           {
  3149.             c = c - 'A' + 10;
  3150.           }
  3151.         if (c >= largest_digit)
  3152.           largest_digit = c;
  3153.         numdigits++;
  3154.  
  3155.         for (count = 0; count < 8; count++)
  3156.           {
  3157.             (shorts[count] *= base);
  3158.             if (count)
  3159.               {
  3160.             shorts[count] += (shorts[count-1] >> 8);
  3161.             shorts[count-1] &= (1<<8)-1;
  3162.               }
  3163.             else shorts[0] += c;
  3164.           }
  3165.  
  3166.         if (p >= token_buffer + maxtoken - 3)
  3167.           p = extend_token_buffer (p);
  3168.         *p++ = (c = getch ());
  3169.           }
  3170.       }
  3171.  
  3172.     if (numdigits == 0)
  3173.       error ("numeric constant with no digits");
  3174.  
  3175.     if (largest_digit >= base)
  3176.       error ("numeric constant contains digits beyond the radix");
  3177.  
  3178.     /* Remove terminating char from the token buffer and delimit the string */
  3179.     *--p = 0;
  3180.  
  3181.     if (floatflag != NOT_FLOAT)
  3182.       {
  3183.         tree type = double_type_node;
  3184.         char f_seen = 0;
  3185.         char l_seen = 0;
  3186.         double value;
  3187.  
  3188.         /* Read explicit exponent if any, and put it in tokenbuf.  */
  3189.  
  3190.         if ((c == 'e') || (c == 'E'))
  3191.           {
  3192.         if (p >= token_buffer + maxtoken - 3)
  3193.           p = extend_token_buffer (p);
  3194.         *p++ = c;
  3195.         c = getch ();
  3196.         if ((c == '+') || (c == '-'))
  3197.           {
  3198.             *p++ = c;
  3199.             c = getch ();
  3200.           }
  3201.         if (! isdigit (c))
  3202.           error ("floating constant exponent has no digits");
  3203.             while (isdigit (c))
  3204.           {
  3205.             if (p >= token_buffer + maxtoken - 3)
  3206.               p = extend_token_buffer (p);
  3207.             *p++ = c;
  3208.             c = getch ();
  3209.           }
  3210.           }
  3211.  
  3212.         *p = 0;
  3213.         errno = 0;
  3214.         value = atof (token_buffer);
  3215. #ifdef ERANGE
  3216.         if (errno == ERANGE && !flag_traditional)
  3217.           {
  3218.         char *p1 = token_buffer;
  3219.         /* Check for "0.0" and variants;
  3220.            Sunos 4 spuriously returns ERANGE for them.  */
  3221.         while (*p1 == '0') p1++;
  3222.         if (*p1 == '.') p1++;
  3223.         while (*p1 == '0') p1++;
  3224.         if (*p1 != 0)
  3225.           warning ("floating point number exceeds range of `double'");
  3226.           }
  3227. #endif
  3228.  
  3229.         /* Read the suffixes to choose a data type.  */
  3230.         while (1)
  3231.           {
  3232.         if (c == 'f' || c == 'F')
  3233.           {
  3234.             if (f_seen)
  3235.               error ("two `f's in floating constant");
  3236.             f_seen = 1;
  3237.             type = float_type_node;
  3238.           }
  3239.         else if (c == 'l' || c == 'L')
  3240.           {
  3241.             if (l_seen)
  3242.               error ("two `l's in floating constant");
  3243.             l_seen = 1;
  3244.             type = long_double_type_node;
  3245.           }
  3246.         else
  3247.           {
  3248.             if (isalnum (c))
  3249.               {
  3250.             error ("garbage at end of number");
  3251.             while (isalnum (c))
  3252.               {
  3253.                 if (p >= token_buffer + maxtoken - 3)
  3254.                   p = extend_token_buffer (p);
  3255.                 *p++ = c;
  3256.                 c = getch ();
  3257.               }
  3258.               }
  3259.             break;
  3260.           }
  3261.         if (p >= token_buffer + maxtoken - 3)
  3262.           p = extend_token_buffer (p);
  3263.         *p++ = c;
  3264.         c = getch ();
  3265.           }
  3266.  
  3267.         /* Create a node with determined type and value.  */
  3268.         yylval.ttype = build_real (type, value);
  3269.  
  3270.         ungetc (c, finput);
  3271.         *p = 0;
  3272.       }
  3273.     else
  3274.       {
  3275.         tree type;
  3276.         int spec_unsigned = 0;
  3277.         int spec_long = 0;
  3278.  
  3279.         while (1)
  3280.           {
  3281.         if (c == 'u' || c == 'U')
  3282.           {
  3283.             if (spec_unsigned)
  3284.               error ("two `u's in integer constant");
  3285.             spec_unsigned = 1;
  3286.           }
  3287.         else if (c == 'l' || c == 'L')
  3288.           {
  3289.             if (spec_long)
  3290.               error ("two `l's in integer constant");
  3291.             spec_long = 1;
  3292.           }
  3293.         else
  3294.           {
  3295.             if (isalnum (c))
  3296.               {
  3297.             error ("garbage at end of number");
  3298.             while (isalnum (c))
  3299.               {
  3300.                 if (p >= token_buffer + maxtoken - 3)
  3301.                   p = extend_token_buffer (p);
  3302.                 *p++ = c;
  3303.                 c = getch ();
  3304.               }
  3305.               }
  3306.             break;
  3307.           }
  3308.         if (p >= token_buffer + maxtoken - 3)
  3309.           p = extend_token_buffer (p);
  3310.         *p++ = c;
  3311.         c = getch ();
  3312.           }
  3313.  
  3314.         ungetc (c, finput);
  3315.  
  3316.         if (shorts[7] | shorts[6] | shorts[5] | shorts[4])
  3317.           warning ("integer constant out of range");
  3318.  
  3319.         /* This is simplified by the fact that our constant
  3320.            is always positive.  */
  3321.         yylval.ttype
  3322.           = build_int_2 ((shorts[3]<<24) + (shorts[2]<<16) + (shorts[1]<<8) + shorts[0],
  3323.                  0);
  3324.  
  3325.         if (!spec_long && !spec_unsigned
  3326.         && int_fits_type_p (yylval.ttype, integer_type_node))
  3327.           type = integer_type_node;
  3328.  
  3329.         else if (!spec_long && base != 10
  3330.              && int_fits_type_p (yylval.ttype, unsigned_type_node))
  3331.           type = unsigned_type_node;
  3332.  
  3333.         else if (!spec_unsigned
  3334.              && int_fits_type_p (yylval.ttype, long_integer_type_node))
  3335.           type = long_integer_type_node;
  3336.  
  3337.         else
  3338.           {
  3339.         type = long_unsigned_type_node;
  3340.         if (! int_fits_type_p (yylval.ttype, long_unsigned_type_node))
  3341.           warning ("integer constant out of range");
  3342.           }
  3343.         TREE_TYPE (yylval.ttype) = type;
  3344.       }
  3345.  
  3346.     value = CONSTANT; break;
  3347.       }
  3348.  
  3349.     case '\'':
  3350.     char_constant:
  3351.       {
  3352.     register int result = 0;
  3353.     register num_chars = 0;
  3354.     int width = TYPE_PRECISION (char_type_node);
  3355.     int max_chars;
  3356.  
  3357.     if (wide_flag) width = TYPE_PRECISION (integer_type_node);
  3358.  
  3359.     max_chars = TYPE_PRECISION (integer_type_node) / width;
  3360.  
  3361.     while (1)
  3362.       {
  3363.       tryagain:
  3364.  
  3365.         c = getch ();
  3366.  
  3367.         if (c == '\'' || c == EOF)
  3368.           break;
  3369.  
  3370.         if (c == '\\')
  3371.           {
  3372.         c = readescape ();
  3373.         if (c < 0)
  3374.           goto tryagain;
  3375.         if (width < HOST_BITS_PER_INT
  3376.             && (unsigned) c >= (1 << width))
  3377.           warning ("escape sequence out of range for character");
  3378.           }
  3379.         else if (c == '\n')
  3380.           {
  3381.         if (pedantic)
  3382.           warning ("ANSI C forbids newline in character constant");
  3383.         lineno++;
  3384.           }
  3385.  
  3386.         num_chars++;
  3387.         if (num_chars > maxtoken - 4)
  3388.           extend_token_buffer (token_buffer);
  3389.  
  3390.         token_buffer[num_chars] = c;
  3391.  
  3392.         /* Merge character into result; ignore excess chars.  */
  3393.         if (num_chars < max_chars + 1)
  3394.           {
  3395.         if (width < HOST_BITS_PER_INT)
  3396.           result = (result << width) | (c & ((1 << width) - 1));
  3397.         else
  3398.           result = c;
  3399.           }
  3400.       }
  3401.  
  3402.     token_buffer[num_chars + 1] = '\'';
  3403.     token_buffer[num_chars + 2] = 0;
  3404.  
  3405.     if (c != '\'')
  3406.       error ("malformatted character constant");
  3407.     else if (num_chars == 0)
  3408.       error ("empty character constant");
  3409.     else if (num_chars > max_chars)
  3410.       {
  3411.         num_chars = max_chars;
  3412.         error ("character constant too long");
  3413.       }
  3414.     else if (num_chars != 1 && ! flag_traditional)
  3415.       warning ("multi-character character constant");
  3416.  
  3417.     /* If char type is signed, sign-extend the constant.  */
  3418.     if (! wide_flag)
  3419.       {
  3420.         int num_bits = num_chars * width;
  3421.         if (TREE_UNSIGNED (char_type_node)
  3422.         || ((result >> (num_bits - 1)) & 1) == 0)
  3423.           yylval.ttype
  3424.         = build_int_2 (result & ((unsigned) ~0
  3425.                      >> (HOST_BITS_PER_INT - num_bits)),
  3426.                    0);
  3427.         else
  3428.           yylval.ttype
  3429.         = build_int_2 (result | ~((unsigned) ~0
  3430.                       >> (HOST_BITS_PER_INT - num_bits)),
  3431.                    -1);
  3432.         TREE_TYPE (yylval.ttype) = char_type_node;
  3433.       }
  3434.     else
  3435.       {
  3436.         yylval.ttype = build_int_2 (result, 0);
  3437.         TREE_TYPE (yylval.ttype) = integer_type_node;
  3438.       }
  3439.     value = CONSTANT; break;
  3440.       }
  3441.  
  3442.     case '"':
  3443.     string_constant:
  3444.       {
  3445.     int *widep;
  3446.     register char *p;
  3447.  
  3448.     c = getch ();
  3449.     p = token_buffer + 1;
  3450.  
  3451.     if (wide_flag)
  3452.       widep = wide_buffer;
  3453.  
  3454.     while (c != '"' && c >= 0)
  3455.       {
  3456.         if (c == '\\')
  3457.           {
  3458.         c = readescape ();
  3459.         if (c < 0)
  3460.           goto skipnewline;
  3461.         if (!wide_flag && c >= (1 << BITS_PER_UNIT))
  3462.           warning ("escape sequence out of range for character");
  3463.           }
  3464.         else if (c == '\n')
  3465.           {
  3466.         if (pedantic)
  3467.           warning ("ANSI C forbids newline in string constant");
  3468.         lineno++;
  3469.           }
  3470.  
  3471.         /* Store the char in C into the appropriate buffer.  */
  3472.  
  3473.         if (wide_flag)
  3474.           {
  3475.         if (widep == wide_buffer + max_wide)
  3476.           {
  3477.             int n = widep - wide_buffer;
  3478.             max_wide *= 2;
  3479.             wide_buffer = (int *) xrealloc (wide_buffer, max_wide + 1);
  3480.             widep = wide_buffer + n;
  3481.           }
  3482.         *widep++ = c;
  3483.           }
  3484.         else
  3485.           {
  3486.         if (p == token_buffer + maxtoken)
  3487.           p = extend_token_buffer (p);
  3488.         *p++ = c;
  3489.           }
  3490.  
  3491.       skipnewline:
  3492.         c = getch ();
  3493.         if (c == EOF) {
  3494.         error("Unterminated string");
  3495.         break;
  3496.         }
  3497.       }
  3498.  
  3499.     /* We have read the entire constant.
  3500.        Construct a STRING_CST for the result.  */
  3501.  
  3502.     if (wide_flag)
  3503.       {
  3504.         /* If this is a L"..." wide-string, make a vector
  3505.            of the ints in wide_buffer.  */
  3506.         *widep = 0;
  3507.         /* We have not implemented the case where `int'
  3508.            on the target and on the execution machine differ in size.  */
  3509.         assert (TYPE_PRECISION (integer_type_node) == sizeof (int) * BITS_PER_UNIT);
  3510.         yylval.ttype = build_string ((widep - wide_buffer) * sizeof (int),
  3511.                      (char *)wide_buffer);
  3512.         TREE_TYPE (yylval.ttype) = int_array_type_node;
  3513.       }
  3514.     else
  3515.       {
  3516.         *p = 0;
  3517.         yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
  3518.         TREE_TYPE (yylval.ttype) = char_array_type_node;
  3519.       }
  3520.  
  3521.     *p++ = '"';
  3522.     *p = 0;
  3523.  
  3524.     value = STRING; break;
  3525.       }
  3526.  
  3527.     case '+':
  3528.     case '-':
  3529.     case '&':
  3530.     case '|':
  3531.     case '<':
  3532.     case '>':
  3533.     case '*':
  3534.     case '/':
  3535.     case '%':
  3536.     case '^':
  3537.     case '!':
  3538.     case '=':
  3539.       {
  3540.     register int c1;
  3541.  
  3542.       combine:
  3543.  
  3544.     switch (c)
  3545.       {
  3546.       case '+':
  3547.         yylval.code = PLUS_EXPR; break;
  3548.       case '-':
  3549.         yylval.code = MINUS_EXPR; break;
  3550.       case '&':
  3551.         yylval.code = BIT_AND_EXPR; break;
  3552.       case '|':
  3553.         yylval.code = BIT_IOR_EXPR; break;
  3554.       case '*':
  3555.         yylval.code = MULT_EXPR; break;
  3556.       case '/':
  3557.         yylval.code = TRUNC_DIV_EXPR; break;
  3558.       case '%':
  3559.         yylval.code = TRUNC_MOD_EXPR; break;
  3560.       case '^':
  3561.         yylval.code = BIT_XOR_EXPR; break;
  3562.       case LSHIFT:
  3563.         yylval.code = LSHIFT_EXPR; break;
  3564.       case RSHIFT:
  3565.         yylval.code = RSHIFT_EXPR; break;
  3566.       case '<':
  3567.         yylval.code = LT_EXPR; break;
  3568.       case '>':
  3569.         yylval.code = GT_EXPR; break;
  3570.       }
  3571.  
  3572.     token_buffer[1] = c1 = getch ();
  3573.     token_buffer[2] = 0;
  3574.  
  3575.     if (c1 == '=')
  3576.       {
  3577.         switch (c)
  3578.           {
  3579.           case '<':
  3580.         value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
  3581.           case '>':
  3582.         value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
  3583.           case '!':
  3584.         value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
  3585.           case '=':
  3586.         value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
  3587.           }
  3588.         value = ASSIGN; goto done;
  3589.       }
  3590.     else if (c == c1)
  3591.       switch (c)
  3592.         {
  3593.         case '+':
  3594.           value = PLUSPLUS; goto done;
  3595.         case '-':
  3596.           value = MINUSMINUS; goto done;
  3597.         case '&':
  3598.           value = ANDAND; goto done;
  3599.         case '|':
  3600.           value = OROR; goto done;
  3601.         case '<':
  3602.           c = LSHIFT;
  3603.           goto combine;
  3604.         case '>':
  3605.           c = RSHIFT;
  3606.           goto combine;
  3607.         }
  3608.     else if ((c == '-') && (c1 == '>'))
  3609.       {
  3610.         nextchar = skip_white_space (getch ());
  3611.         if (nextchar == '(')
  3612.           {
  3613.         int next_c = skip_white_space (getch ());
  3614.         if (next_c == ')')
  3615.           {
  3616.             nextchar = -1;
  3617.             value = POINTSAT_LEFT_RIGHT;
  3618.             goto done;
  3619.           }
  3620.         ungetc (next_c, finput);
  3621.           }
  3622.         value = POINTSAT;
  3623.         goto done;
  3624.       }
  3625.     else if (c1 == '?' && (c == '<' || c == '>'))
  3626.       {
  3627.         token_buffer[3] = 0;
  3628.  
  3629.         c1 = getch ();
  3630.         yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
  3631.         if (c1 == '=')
  3632.           {
  3633.         /* <?= or >?= expression.  */
  3634.         token_buffer[2] = c1;
  3635.         value = ASSIGN;
  3636.           }
  3637.         else
  3638.           {
  3639.         value = MIN_MAX;
  3640.         nextchar = c1;
  3641.           }
  3642.         if (pedantic)
  3643.           error ("use of `operator %s' is not standard C++",
  3644.              token_buffer);
  3645.         goto done;
  3646.       }
  3647.  
  3648.     nextchar = c1;
  3649.     token_buffer[1] = 0;
  3650.  
  3651.     if ((c == '<') || (c == '>'))
  3652.       value = ARITHCOMPARE;
  3653.     else value = c;
  3654.     goto done;
  3655.       }
  3656.  
  3657.     case ':':
  3658.       c = getch ();
  3659.       if (c == ':')
  3660.     {
  3661.       token_buffer[1] = ':';
  3662.       token_buffer[2] = '\0';
  3663.       value = SCOPE;
  3664.       yylval.itype = 1;
  3665.     }
  3666.       else
  3667.     {
  3668.       nextchar = c;
  3669.       value = ':';
  3670.     }
  3671.       break;
  3672.  
  3673.     case 0:
  3674.       /* Don't make yyparse think this is eof.  */
  3675.       value = 1;
  3676.       break;
  3677.  
  3678.     case '(':
  3679.       /* try, weakly, to handle casts to pointers to functions.  */
  3680.       nextchar = skip_white_space (getch ());
  3681.       if (nextchar == '*')
  3682.     {
  3683.       int next_c = skip_white_space (getch ());
  3684.       if (next_c == ')')
  3685.         {
  3686.           nextchar = -1;
  3687.           yylval.ttype = build1 (INDIRECT_REF, 0, 0);
  3688.           value = PAREN_STAR_PAREN;
  3689.         }
  3690.       else
  3691.         {
  3692.           ungetc (next_c, finput);
  3693.           value = c;
  3694.         }
  3695.     }
  3696.       /* Go down for a (X::*) or (X::&).  */
  3697.       else if (isalpha (nextchar) || nextchar == '_' || nextchar == '$')
  3698.     {
  3699.       YYSTYPE this_yylval = yylval;
  3700.       tree this_lastiddecl = lastiddecl;
  3701.       nextyychar = yylex ();
  3702.       if (nextyychar == TYPENAME_SCOPE)
  3703.         {
  3704.           if (nextchar < 0)
  3705.         nextchar = skip_white_space (getch ());
  3706.           if (nextchar == '*' || nextchar == '&')
  3707.         {
  3708.           int next_c = skip_white_space (getch ());
  3709.           if (next_c == ')')
  3710.             {
  3711.               nextyychar = -1;
  3712.               if (nextchar == '*')
  3713.             {
  3714.               value = PAREN_X_SCOPE_STAR_PAREN;
  3715.               yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype,
  3716.                                build_parse_node (INDIRECT_REF, 0));
  3717.             }
  3718.               else
  3719.             {
  3720.               value = PAREN_X_SCOPE_REF_PAREN;
  3721.               yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype,
  3722.                                build_parse_node (ADDR_EXPR, 0));
  3723.             }
  3724.               nextchar = -1;
  3725.             }
  3726.           else
  3727.             {
  3728.               ungetc (next_c, finput);
  3729.               nextyylval = yylval;
  3730.               nextlastiddecl = lastiddecl;
  3731.               yylval = this_yylval;
  3732.               lastiddecl = this_lastiddecl;
  3733.               value = c;
  3734.             }
  3735.         }
  3736.           else
  3737.         {
  3738.           nextyylval = yylval;
  3739.           nextlastiddecl = lastiddecl;
  3740.           yylval = this_yylval;
  3741.           lastiddecl = this_lastiddecl;
  3742.           value = c;
  3743.         }
  3744.         }
  3745.       else
  3746.         {
  3747.           nextyylval = yylval;
  3748.           nextlastiddecl = lastiddecl;
  3749.           yylval = this_yylval;
  3750.           lastiddecl = this_lastiddecl;
  3751.           value = c;
  3752.         }
  3753.     }
  3754.       else if (nextchar == ')')
  3755.     {
  3756.       nextchar = -1;
  3757.       yylval.ttype = NULL_TREE;
  3758.       value = LEFT_RIGHT;
  3759.     }
  3760.       else value = c;
  3761.       break;
  3762.  
  3763.     default:
  3764.       value = c;
  3765.     }
  3766.  
  3767. done:
  3768. /*  yylloc.last_line = lineno; */
  3769. #ifdef GATHER_STATISTICS
  3770.   token_count[value] += 1;
  3771. #endif
  3772.  
  3773.   return value;
  3774. }
  3775.  
  3776. typedef enum
  3777. {
  3778.   d_kind, t_kind, s_kind, r_kind, e_kind, c_kind,
  3779.   id_kind, op_id_kind, perm_list_kind, temp_list_kind,
  3780.   x_kind, lang_decl, lang_type, all_kinds
  3781. } tree_node_kind;
  3782. extern int tree_node_kinds[];
  3783. extern int tree_node_sizes[];
  3784. extern char *tree_node_kind_names[];
  3785.  
  3786. /* Place to save freed lang_decls which were allocated on the
  3787.    permanent_obstack.  @@ Not currently used.  */
  3788. tree free_lang_decl_chain;
  3789.  
  3790. tree
  3791. build_lang_decl (code, name, type)
  3792.      enum tree_code code;
  3793.      tree name;
  3794.      tree type;
  3795. {
  3796.   extern struct obstack *current_obstack, *saveable_obstack;
  3797.   extern struct obstack permanent_obstack;
  3798.   register tree t = build_decl (code, name, type);
  3799.   struct obstack *obstack = current_obstack;
  3800.   register int i = sizeof (struct lang_decl) / sizeof (int);
  3801.   register int *pi;
  3802.  
  3803.   if (! TREE_PERMANENT (t))
  3804.     obstack = saveable_obstack;
  3805.  
  3806. #ifdef LANG_DECL_PERMANENT
  3807.   if (free_lang_decl_chain && obstack == &permanent_obstack)
  3808.     {
  3809.       pi = (int *)free_lang_decl_chain;
  3810.       free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
  3811.     }
  3812.   else
  3813.     pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3814. #else
  3815.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3816. #endif
  3817.  
  3818.   while (i > 0)
  3819.     pi[--i] = 0;
  3820.  
  3821.   DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
  3822. #ifdef LANG_DECL_PERMANENT
  3823.   LANG_DECL_PERMANENT ((struct lang_decl *) pi)
  3824.     = obstack == &permanent_obstack;
  3825. #endif
  3826.   DECL_MAIN_VARIANT (t) = t;
  3827.   DECL_ORIGINAL_NAME (t) = name;
  3828.   if (current_lang_name == lang_name_cplusplus)
  3829.     {
  3830.       DECL_LANGUAGE (t) = lang_cplusplus;
  3831.  
  3832. #ifndef NO_AUTO_OVERLOAD
  3833.       if (code == FUNCTION_DECL && name != 0
  3834.       && ! (IDENTIFIER_LENGTH (name) == 4
  3835.         && IDENTIFIER_POINTER (name)[0] == 'm'
  3836.         && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
  3837.       && ! (IDENTIFIER_LENGTH (name) > 10
  3838.         && IDENTIFIER_POINTER (name)[0] == '_'
  3839.         && IDENTIFIER_POINTER (name)[1] == '_'
  3840.         && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
  3841.     TREE_OVERLOADED (name) = 1;
  3842. #endif
  3843.     }
  3844.   else if (current_lang_name == lang_name_c)
  3845.     DECL_LANGUAGE (t) = lang_c;
  3846.   else abort ();
  3847.  
  3848. #ifdef GATHER_STATISTICS
  3849.   tree_node_kinds[(int)lang_decl] += 1;
  3850.   tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
  3851. #endif
  3852.  
  3853.   return t;
  3854. }
  3855.  
  3856. tree
  3857. build_lang_field_decl (code, name, type)
  3858.      enum tree_code code;
  3859.      tree name;
  3860.      tree type;
  3861. {
  3862.   extern struct obstack *current_obstack, *saveable_obstack;
  3863.   register tree t = build_decl (code, name, type);
  3864.   struct obstack *obstack = current_obstack;
  3865.   register int i = sizeof (struct lang_decl_flags) / sizeof (int);
  3866.   register int *pi;
  3867.  
  3868.   if (! TREE_PERMANENT (t))
  3869.     obstack = saveable_obstack;
  3870.  
  3871.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
  3872.   while (i > 0)
  3873.     pi[--i] = 0;
  3874.  
  3875.   DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
  3876.   return t;
  3877. }
  3878.  
  3879. tree
  3880. make_lang_type (code)
  3881.      enum tree_code code;
  3882. {
  3883.   extern struct obstack *current_obstack, *saveable_obstack;
  3884.   register tree t = make_node (code);
  3885.   struct obstack *obstack = current_obstack;
  3886.   register int i = sizeof (struct lang_type) / sizeof (int);
  3887.   register int *pi;
  3888.  
  3889.   if (! TREE_PERMANENT (t))
  3890.     obstack = saveable_obstack;
  3891.  
  3892.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
  3893.   while (i > 0)
  3894.     pi[--i] = 0;
  3895.  
  3896.   TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
  3897.   CLASSTYPE_MAIN_VARIANT (t) = t;
  3898.   CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t);
  3899.   CLASSTYPE_INTERFACE_UNKNOWN (t) = interface_unknown;
  3900.   CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
  3901.  
  3902.   /* Make sure this is laid out, for ease of use later.
  3903.      In the presence of parse errors, the normal was of assuring
  3904.      this might not ever get executed, so we lay it out *immediately*.  */
  3905.   build_pointer_type (t);
  3906.  
  3907. #ifdef GATHER_STATISTICS
  3908.   tree_node_kinds[(int)lang_type] += 1;
  3909.   tree_node_sizes[(int)lang_type] += sizeof(struct lang_type);
  3910. #endif
  3911.  
  3912.   return t;
  3913. }
  3914.  
  3915. void
  3916. copy_decl_lang_specific (decl)
  3917.      tree decl;
  3918. {
  3919.   extern struct obstack *current_obstack, *saveable_obstack;
  3920.   register int *old = (int *)DECL_LANG_SPECIFIC (decl);
  3921.   struct obstack *obstack = current_obstack;
  3922.   register int i = sizeof (struct lang_decl) / sizeof (int);
  3923.   register int *pi;
  3924.  
  3925.   if (! TREE_PERMANENT (decl))
  3926.     obstack = saveable_obstack;
  3927.  
  3928.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3929.   while (i-- > 0)
  3930.     pi[i] = old[i];
  3931.  
  3932.   DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi;
  3933.  
  3934. #ifdef GATHER_STATISTICS
  3935.   tree_node_kinds[(int)lang_decl] += 1;
  3936.   tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
  3937. #endif
  3938. }
  3939.  
  3940. void
  3941. copy_type_lang_specific (type)
  3942.      tree type;
  3943. {
  3944.   extern struct obstack *current_obstack, *saveable_obstack;
  3945.   register int *old = (int *)TYPE_LANG_SPECIFIC (type);
  3946.   struct obstack *obstack = current_obstack;
  3947.   register int i = sizeof (struct lang_type) / sizeof (int);
  3948.   register int *pi;
  3949.  
  3950.   if (! TREE_PERMANENT (type))
  3951.     obstack = saveable_obstack;
  3952.  
  3953.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
  3954.   while (i-- > 0)
  3955.     pi[i] = old[i];
  3956.  
  3957.   TYPE_LANG_SPECIFIC (type) = (struct lang_type *) pi;
  3958.   CLASSTYPE_AS_LIST (type) = build_tree_list (NULL_TREE, type);
  3959.   if (CLASSTYPE_N_BASECLASSES (type) > 0)
  3960.     CLASSTYPE_BASECLASSES (type) = (tree *)obstack_copy (obstack, CLASSTYPE_BASECLASSES (type), (CLASSTYPE_N_BASECLASSES (type)+1) * sizeof (tree));
  3961.  
  3962. #ifdef GATHER_STATISTICS
  3963.   tree_node_kinds[(int)lang_type] += 1;
  3964.   tree_node_sizes[(int)lang_type] += sizeof(struct lang_type);
  3965. #endif
  3966. }
  3967.  
  3968. tree
  3969. build_with_cleanup (exp, type, rtl)
  3970.      tree exp;
  3971.      tree type;
  3972.      struct rtx_def *rtl;
  3973. {
  3974.   if (type != NULL_TREE || TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (exp)))
  3975.     {
  3976.       tree rval = make_node (WITH_CLEANUP_EXPR);
  3977.  
  3978.       if (type == NULL_TREE)
  3979.     type = TREE_TYPE (exp);
  3980.  
  3981.       TREE_OPERAND (rval, 0) = exp;
  3982.       TREE_OPERAND (rval, 1) = make_node (RTL_EXPR);
  3983.       TREE_OPERAND (rval, 2) = build_delete (TYPE_POINTER_TO (type),
  3984.                          build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (rval, 1)),
  3985.                          integer_two_node, LOOKUP_NORMAL, 0);
  3986.       if (rtl != 0)
  3987.     RTL_EXPR_RTL (TREE_OPERAND (rval, 1)) = rtl;
  3988.       if (TREE_CODE (exp) == CALL_EXPR
  3989.       && TREE_VALUE (TREE_OPERAND (exp, 1)) == NULL_TREE)
  3990.     TREE_VALUE (TREE_OPERAND (exp, 1)) = TREE_OPERAND (rval, 1);
  3991.       TREE_TYPE (rval) = type;
  3992.       return rval;
  3993.     }
  3994.   return NULL_TREE;
  3995. }
  3996.  
  3997. void
  3998. dump_time_statistics ()
  3999. {
  4000.   register tree prev = 0, decl, next;
  4001.   int this_time = my_gettime ();
  4002.   TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
  4003.     += this_time - body_time;
  4004.  
  4005.   fprintf (stderr, "\n******\n");
  4006.   print_time ("header files (total)", header_time);
  4007.   print_time ("main file (total)", this_time - body_time);
  4008.   fprintf (stderr, "ratio = %g : 1\n",
  4009.        (double)header_time / (double)(this_time - body_time));
  4010.   fprintf (stderr, "\n******\n");
  4011.  
  4012.   for (decl = filename_times; decl; decl = next)
  4013.     {
  4014.       next = IDENTIFIER_GLOBAL_VALUE (decl);
  4015.       IDENTIFIER_GLOBAL_VALUE (decl) = prev;
  4016.       prev = decl;
  4017.     }
  4018.  
  4019.   for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
  4020.     print_time (IDENTIFIER_POINTER (decl),
  4021.         TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
  4022. }
  4023.  
  4024. void
  4025. compiler_error (s, v, v2)
  4026.      char *s;
  4027.      int v, v2;            /* @@also used as pointer */
  4028. {
  4029.   char buf[1024];
  4030.   sprintf (buf, s, v, v2);
  4031.   error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
  4032. }
  4033.  
  4034. void
  4035. compiler_error_with_decl (decl, s)
  4036.      tree decl;
  4037.      char *s;
  4038. {
  4039.   char *name;
  4040.   count_error (0);
  4041.  
  4042.   report_error_function (0);
  4043.  
  4044.   if (TREE_CODE (decl) == PARM_DECL)
  4045.     fprintf (stderr, "%s:%d: ",
  4046.          DECL_SOURCE_FILE (DECL_CONTEXT (decl)),
  4047.          DECL_SOURCE_LINE (DECL_CONTEXT (decl)));
  4048.   else
  4049.     fprintf (stderr, "%s:%d: ",
  4050.          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  4051.  
  4052.   name = lang_printable_name (decl);
  4053.   if (name)
  4054.     fprintf (stderr, s, name);
  4055.   else
  4056.     fprintf (stderr, s, "((anonymous))");
  4057.   fprintf (stderr, " (compiler error)\n");
  4058. }
  4059.